Unity-Technologies/UnityCsReference · error · NotSupportedException

ApiCompatibilityLevel.{0} is not supported!

Error message

ApiCompatibilityLevel.{0} is not supported!

What it means

Thrown by ApiCompatibilityLevelToDotNetProfileArgument when the scripting backend is Mono and the ApiCompatibilityLevel is neither NET_Unity_4_8 nor NET_Standard. Unity's Mono backend only supports these two API compatibility levels; any other enum value falls through to the default case and throws NotSupportedException.

Source

Thrown at Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:369

            "NET_4_0=1",
            "UNITY_AOT=1",
            "NET_STANDARD_2_0=1",
            "NET_UNITY_4_8=1",
            "NET_STANDARD=1",
        }).ToArray();

        internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibilityLevel compatibilityLevel, BuildTarget target, ScriptingBackend scriptingBackend)
        {
            if (scriptingBackend == ScriptingBackend.Mono)
            {
                switch (compatibilityLevel)
                {
                    case ApiCompatibilityLevel.NET_Unity_4_8:
                    case ApiCompatibilityLevel.NET_Standard:
                        return "unityjit";

                    default:
                        throw new NotSupportedException(string.Format("ApiCompatibilityLevel.{0} is not supported!", compatibilityLevel));
                }
            }

            if (scriptingBackend == ScriptingBackend.IL2CPP)
            {
                switch (compatibilityLevel)
                {
                    case ApiCompatibilityLevel.NET_Unity_4_8:
                    case ApiCompatibilityLevel.NET_Standard:
                        return "unityaot-" + BuildTargetDiscovery.GetPlatformProfileSuffix(target);
#pragma warning disable CS0618
                    case ApiCompatibilityLevel.NET:
#pragma warning restore CS0618
                        // We won't need the profile argument going forward.  Dropping this option also acts as an indicator to il2cpp to use the new bcl.
                        return null;

                    default:
                        throw new NotSupportedException(string.Format("ApiCompatibilityLevel.{0} is not supported!", compatibilityLevel));

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Set ApiCompatibilityLevel to NET_Standard or NET_Unity_4_8 for Mono backend builds via PlayerSettings.SetApiCompatibilityLevel.
  2. Switch to IL2CPP backend if a wider range of API compatibility levels is needed.
  3. After a Unity upgrade, run the API Updater and verify PlayerSettings.apiCompatibilityLevel in ProjectSettings/ProjectSettings.asset.

Example fix

// before
PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, ApiCompatibilityLevel.NET);
// Mono build throws at IL2CPPUtils

// after
PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, ApiCompatibilityLevel.NET_Standard);
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<ApiCompatibilityLevel> s_monoSupported = new()
{
    ApiCompatibilityLevel.NET_Unity_4_8,
    ApiCompatibilityLevel.NET_Standard
};

void ValidateApiCompatibility(ApiCompatibilityLevel level, ScriptingBackend backend)
{
    if (backend == ScriptingBackend.Mono && !s_monoSupported.Contains(level))
        throw new ArgumentException(
            $"ApiCompatibilityLevel.{level} is not supported with Mono backend. " +
            "Use NET_Standard or NET_Unity_4_8.");
}

// Before building:
ValidateApiCompatibility(
    PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone),
    PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone));

Prevention

When it happens

Trigger: Building with ScriptingBackend.Mono and an ApiCompatibilityLevel other than NET_Unity_4_8 or NET_Standard — e.g., the deprecated ApiCompatibilityLevel.NET or a legacy .NET 2.0 / .NET 2.0 Subset value if the enum is extended or remapped.

Common situations: Upgrading a project from an old Unity version that used deprecated ApiCompatibilityLevel values, editor scripts that set PlayerSettings.SetApiCompatibilityLevel to a value not supported by the Mono backend, or migration scripts that carry over stale PlayerSettings.

Related errors


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