Unity-Technologies/UnityCsReference · error · ArgumentException
Android textureCompressionFormats can't be null or empty
Error message
Android textureCompressionFormats can't be null or empty
What it means
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.
Source
Thrown at Editor/Mono/PlayerSettingsAndroid.bindings.cs:902
public static extern bool optimizedFramePacing
{
[NativeMethod("GetAndroidUseSwappy")]
get;
[NativeMethod("SetAndroidUseSwappy")]
set;
}
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
{View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
PlayerSettings.Android.textureCompressionFormats = formats; // formats is null/empty
// after
PlayerSettings.Android.textureCompressionFormats =
(formats != null && formats.Length > 0) ? formats : new[] { TextureCompressionFormat.ETC2 }; Defensive patterns
Strategy: validation
Validate before calling
var formats = (value != null && value.Length > 0)
? value
: new[] { TextureCompressionFormat.ETC2 };
PlayerSettings.Android.textureCompressionFormats = formats; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {format} can't be used as a target texture compression for A
- Attempting to retrieve icon layer {layer}, while the icon on
- Attempting to set icon layer {layer}, while icon only suppor
- Attempting to assign an incorrect amount of layers to an Pla
- The provided target platform group name ({buildTargetName})
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/f066cd2dbf773c36.
Report an issue: GitHub.