Unity-Technologies/UnityCsReference · error · ArgumentException

{format} can't be used as a target texture compression for A

Error message

{format} can't be used as a target texture compression for Android

What it means

Thrown by the PlayerSettings.Android.textureCompressionFormats setter when any format in the array is TextureCompressionFormat.Unknown or TextureCompressionFormat.BPTC. Unknown is not a real format (it's a sentinel/default), and BPTC (BC6H/BC7) is not supported as an Android target compression format — it's a desktop/DX11 format. The build pipeline cannot include either in an Android APK.

Source

Thrown at Editor/Mono/PlayerSettingsAndroid.bindings.cs:908

            }

            public static TextureCompressionFormat[] textureCompressionFormats
            {
                get
                {
                    return GetTextureCompressionFormatsImpl(BuildTarget.Android);
                }
                set
                {
                    if (value == null || value.Length == 0)
                    {
                        throw new ArgumentException($"Android textureCompressionFormats can't be null or empty");
                    }
                    foreach (var format in value)
                    {
                        if (format == TextureCompressionFormat.Unknown || format == TextureCompressionFormat.BPTC)
                        {
                            throw new ArgumentException($"{format} can't be used as a target texture compression for Android");
                        }
                    }
                    SetTextureCompressionFormatsImpl(BuildTarget.Android, value);
                }
            }

            // Google Play App Dependencies info.
            [NativeProperty("AndroidReportGooglePlayAppDependencies", TargetType.Function)]
            public static extern bool reportGooglePlayAppDependencies { get; set; }

            public static extern AndroidApplicationEntry applicationEntry
            {
                [NativeMethod("GetAndroidApplicationEntry")]
                get;
                [NativeMethod("SetAndroidApplicationEntry")]
                set;
            }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Filter out invalid formats before assignment: formats.Where(f => f != TextureCompressionFormat.Unknown && f != TextureCompressionFormat.BPTC).
  2. Use Android-supported formats only: ETC2, ETC, ASTC, DXT, PVRTC, ATC as applicable.
  3. Initialize arrays explicitly rather than relying on enum default values.

Example fix

// before
PlayerSettings.Android.textureCompressionFormats = allFormats; // contains Unknown/BPTC

// after
var androidFormats = allFormats
    .Where(f => f != TextureCompressionFormat.Unknown && f != TextureCompressionFormat.BPTC)
    .ToArray();
PlayerSettings.Android.textureCompressionFormats = androidFormats;
Defensive patterns

Strategy: validation

Validate before calling

var validFormats = value
    .Where(f => f != TextureCompressionFormat.Unknown && f != TextureCompressionFormat.BPTC)
    .ToArray();
PlayerSettings.Android.textureCompressionFormats = validFormats;

Prevention

When it happens

Trigger: Passing an array containing TextureCompressionFormat.Unknown or TextureCompressionFormat.BPTC to the textureCompressionFormats setter. This happens when copying compression format lists from a PC/Mac build configuration to Android, or when a format enum defaults to Unknown (value 0) in an uninitialized array.

Common situations: Cross-platform build scripts that share a compression format list across platforms; uninitialized arrays where elements default to the 0 enum value (Unknown); configuration tools that present all TextureCompressionFormat values without filtering for Android.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/49d73cc614fd9cd6. Report an issue: GitHub.