{"record":{"id":"738e7e5764fd8570","repo":"Unity-Technologies/UnityCsReference","slug":"apicompatibilitylevel-0-is-not-supported","errorCode":null,"errorMessage":"ApiCompatibilityLevel.{0} is not supported!","messagePattern":"ApiCompatibilityLevel\\.(.+?) is not supported!","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs","lineNumber":369,"sourceCode":"            \"NET_4_0=1\",\n            \"UNITY_AOT=1\",\n            \"NET_STANDARD_2_0=1\",\n            \"NET_UNITY_4_8=1\",\n            \"NET_STANDARD=1\",\n        }).ToArray();\n\n        internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibilityLevel compatibilityLevel, BuildTarget target, ScriptingBackend scriptingBackend)\n        {\n            if (scriptingBackend == ScriptingBackend.Mono)\n            {\n                switch (compatibilityLevel)\n                {\n                    case ApiCompatibilityLevel.NET_Unity_4_8:\n                    case ApiCompatibilityLevel.NET_Standard:\n                        return \"unityjit\";\n\n                    default:\n                        throw new NotSupportedException(string.Format(\"ApiCompatibilityLevel.{0} is not supported!\", compatibilityLevel));\n                }\n            }\n\n            if (scriptingBackend == ScriptingBackend.IL2CPP)\n            {\n                switch (compatibilityLevel)\n                {\n                    case ApiCompatibilityLevel.NET_Unity_4_8:\n                    case ApiCompatibilityLevel.NET_Standard:\n                        return \"unityaot-\" + BuildTargetDiscovery.GetPlatformProfileSuffix(target);\n#pragma warning disable CS0618\n                    case ApiCompatibilityLevel.NET:\n#pragma warning restore CS0618\n                        // We won't need the profile argument going forward.  Dropping this option also acts as an indicator to il2cpp to use the new bcl.\n                        return null;\n\n                    default:\n                        throw new NotSupportedException(string.Format(\"ApiCompatibilityLevel.{0} is not supported!\", compatibilityLevel));","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs#L351-L387","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set ApiCompatibilityLevel to NET_Standard or NET_Unity_4_8 for Mono backend builds via PlayerSettings.SetApiCompatibilityLevel.","Switch to IL2CPP backend if a wider range of API compatibility levels is needed.","After a Unity upgrade, run the API Updater and verify PlayerSettings.apiCompatibilityLevel in ProjectSettings/ProjectSettings.asset."],"exampleFix":"// before\nPlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, ApiCompatibilityLevel.NET);\n// Mono build throws at IL2CPPUtils\n\n// after\nPlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, ApiCompatibilityLevel.NET_Standard);","handlingStrategy":"validation","validationCode":"static readonly HashSet<ApiCompatibilityLevel> s_monoSupported = new()\n{\n    ApiCompatibilityLevel.NET_Unity_4_8,\n    ApiCompatibilityLevel.NET_Standard\n};\n\nvoid ValidateApiCompatibility(ApiCompatibilityLevel level, ScriptingBackend backend)\n{\n    if (backend == ScriptingBackend.Mono && !s_monoSupported.Contains(level))\n        throw new ArgumentException(\n            $\"ApiCompatibilityLevel.{level} is not supported with Mono backend. \" +\n            \"Use NET_Standard or NET_Unity_4_8.\");\n}\n\n// Before building:\nValidateApiCompatibility(\n    PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone),\n    PlayerSettings.GetScriptingBackend(BuildTargetGroup.Standalone));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After a Unity upgrade, verify PlayerSettings.apiCompatibilityLevel is set to NET_Standard or NET_Unity_4_8.","Run the API Updater when prompted after upgrades.","Avoid editor scripts that set deprecated ApiCompatibilityLevel values for Mono builds."],"tags":["unity","build-pipeline","il2cpp","api-compatibility","mono-backend","player-settings"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}