{"record":{"id":"f066cd2dbf773c36","repo":"Unity-Technologies/UnityCsReference","slug":"android-texturecompressionformats-can-t-be-null-or","errorCode":null,"errorMessage":"Android textureCompressionFormats can't be null or empty","messagePattern":"Android textureCompressionFormats can't be null or empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayerSettingsAndroid.bindings.cs","lineNumber":902,"sourceCode":"            public static extern bool optimizedFramePacing\n            {\n                [NativeMethod(\"GetAndroidUseSwappy\")]\n                get;\n                [NativeMethod(\"SetAndroidUseSwappy\")]\n                set;\n            }\n\n            public static TextureCompressionFormat[] textureCompressionFormats\n            {\n                get\n                {\n                    return GetTextureCompressionFormatsImpl(BuildTarget.Android);\n                }\n                set\n                {\n                    if (value == null || value.Length == 0)\n                    {\n                        throw new ArgumentException($\"Android textureCompressionFormats can't be null or empty\");\n                    }\n                    foreach (var format in value)\n                    {\n                        if (format == TextureCompressionFormat.Unknown || format == TextureCompressionFormat.BPTC)\n                        {\n                            throw new ArgumentException($\"{format} can't be used as a target texture compression for Android\");\n                        }\n                    }\n                    SetTextureCompressionFormatsImpl(BuildTarget.Android, value);\n                }\n            }\n\n            // Google Play App Dependencies info.\n            [NativeProperty(\"AndroidReportGooglePlayAppDependencies\", TargetType.Function)]\n            public static extern bool reportGooglePlayAppDependencies { get; set; }\n\n            public static extern AndroidApplicationEntry applicationEntry\n            {","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayerSettingsAndroid.bindings.cs#L884-L920","documentation":"Thrown by the PlayerSettings.Android.textureCompressionFormats property setter when the assigned array is null or empty. Android requires at least one texture compression format to be specified — the build pipeline needs to know which formats to include in the APK. The formats ETC2 (default) and ASTC are typically required for broad device compatibility.","triggerScenarios":"Setting PlayerSettings.Android.textureCompressionFormats to null or an empty array via an editor script or build pipeline configuration. This commonly happens when programmatically clearing settings or when a configuration object deserializes with no formats specified.","commonSituations":"CI/CD build scripts that configure Android settings from a config file with missing compression format entries; editor automation that resets settings before reconfiguration; upgrade scenarios where the default format list is lost.","solutions":["Always provide at least one valid format: PlayerSettings.Android.textureCompressionFormats = new[] { TextureCompressionFormat.ETC2, TextureCompressionFormat.ASTC };","Read the current value before modifying so you never assign null: start from the existing array and modify in place.","Validate configuration sources at build time and fail early with a clear message if compression formats are missing."],"exampleFix":"// before\nPlayerSettings.Android.textureCompressionFormats = formats; // formats is null/empty\n\n// after\nPlayerSettings.Android.textureCompressionFormats =\n    (formats != null && formats.Length > 0) ? formats : new[] { TextureCompressionFormat.ETC2 };","handlingStrategy":"validation","validationCode":"var formats = (value != null && value.Length > 0)\n    ? value\n    : new[] { TextureCompressionFormat.ETC2 };\nPlayerSettings.Android.textureCompressionFormats = formats;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide at least one valid texture compression format for Android builds.","Read the current value before modifying to avoid accidentally assigning null.","Validate build configuration entries for missing compression format data."],"tags":["unity-editor","android","player-settings","texture-compression","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}