Unity-Technologies/UnityCsReference · error · ArgumentException
The provided target platform group name ({buildTargetName})
Error message
The provided target platform group name ({buildTargetName}) is not valid. What it means
Thrown by PlayerSettings.ValidateBuildTargetNameParameter when the provided build target group name string does not resolve to a known BuildTargetGroup via BuildPipeline.GetBuildTargetGroupByName, returning BuildTargetGroup.Unknown. The only exception is when unknownIsValid is true and the name is an empty string (which represents BuildTargetGroup.Unknown's valid form). This validates that API callers pass a recognized platform name.
Source
Thrown at Editor/Mono/PlayerSettings.bindings.cs:445
{
private PlayerSettings() { }
// Lazily (re)created in GetSerializedObject(); reset to null on reload so it rebuilds on next access
// (the disposable SerializedObject has no field initializer for the generator to reassign after dispose).
[AutoStaticsCleanupOnCodeReload(CleanupStrategy = CleanupStrategy.ResetToDefaultValue)]
private static SerializedObject _serializedObject;
[FreeFunction("GetPlayerSettingsPtr")]
private static extern UnityEngine.Object InternalGetPlayerSettingsObject();
[StaticAccessor("PlayerSettingsBindings", StaticAccessorType.DoubleColon)]
internal static extern PlayerSettings GetProjectSettingsPlayerSettings();
internal static void ValidateBuildTargetNameParameter(string buildTargetName, bool unknownIsValid = false)
{
// The empty string is the valid form of BuildTargetGroup.Unknown, so don't throw an execption for that case.
if (BuildPipeline.GetBuildTargetGroupByName(buildTargetName) == BuildTargetGroup.Unknown && (!unknownIsValid || buildTargetName != ""))
throw new ArgumentException($"The provided target platform group name ({buildTargetName}) is not valid.");
}
internal static SerializedObject GetSerializedObject()
{
if (_serializedObject == null || _serializedObject.targetObject != InternalGetPlayerSettingsObject())
_serializedObject = new SerializedObject(InternalGetPlayerSettingsObject());
return _serializedObject;
}
internal static SerializedProperty FindProperty(string name)
{
SerializedProperty property = GetSerializedObject().FindProperty(name);
if (property == null)
Debug.LogError("Failed to find:" + name);
return property;
}
[Obsolete("Use explicit API instead.")]View on GitHub (pinned to 225b0fbdb5)
Solutions
- Verify the build target name spelling against BuildPipeline.GetBuildTargetGroupByName — use NamedBuildTarget or BuildTarget enum values instead of raw strings where possible.
- Use NamedBuildTarget.FromBuildTargetGroup(BuildTargetGroup.Android) etc. to avoid string-based lookups entirely.
- Check that the build support module for the target platform is installed in your Unity editor.
Example fix
// before
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.Android, defines);
// but if using a raw string name that's misspelled:
ValidateBuildTargetNameParameter("Andriod"); // typo
// after
ValidateBuildTargetNameParameter("Android"); Defensive patterns
Strategy: validation
Validate before calling
if (BuildPipeline.GetBuildTargetGroupByName(buildTargetName) != BuildTargetGroup.Unknown
|| (unknownIsValid && buildTargetName == ""))
// proceed
else
throw new ArgumentException($"Unknown build target: {buildTargetName}"); Prevention
- Use NamedBuildTarget or BuildTarget enum values instead of raw platform name strings.
- Verify the build support module for the target platform is installed.
- Double-check spelling and case of build target group names.
When it happens
Trigger: Calling any PlayerSettings API that internally calls ValidateBuildTargetNameParameter with a misspelled or unrecognized build target group name string. Examples: passing 'Andriod' instead of 'Android', 'iOS' (case-sensitive), or a platform not installed in the current build.
Common situations: Typographical errors in build target names in editor scripts; using a platform name from a build support module that isn't installed; case-sensitivity issues (build target names may be case-sensitive); passing a display name instead of the internal target name.
Related errors
- 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
- Attempting to set an incorrect number of icons for {buildTar
- Value cannot be null. (Parameter 'defines')
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/c9e555e2320e16b0.
Report an issue: GitHub.