Unity-Technologies/UnityCsReference · error · UnityException

Could not find any valid targets to launch on for {0}

Error message

Could not find any valid targets to launch on for {0}

What it means

Wraps a caught NoTargetsFoundException into a UnityException that names the build target, surfacing that no valid runtime target was found to launch the build on. This is the user-facing rethrow after the deployment flow determined no target could accept the build.

Source

Thrown at Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:302

                        throw new NoTargetsFoundException("Could not launch build");
                    }
                });

                taskManager.Run();
            }
            catch (DeploymentOperationFailedException e)
            {
                UnityEngine.Debug.LogException(e);
                EditorUtility.DisplayDialog(e.title, e.Message, "OK");
            }
            catch (DeploymentOperationAbortedException)
            {
                System.Console.WriteLine("Deployment aborted");
            }
            catch (NoTargetsFoundException e)
            {
                Debug.LogException(e);
                throw new UnityException(string.Format("Could not find any valid targets to launch on for {0}", buildTarget));
            }

            return launches;
        }

        [RequiredByNativeCode]
        static public void UpdateBootConfig(BuildTarget target, BootConfigData config, BuildOptions options)
        {
            IBuildPostprocessor postprocessor = ModuleManager.GetBuildPostProcessor(target);
            if (postprocessor != null)
                postprocessor.UpdateBootConfig(target, config, options);

            foreach (var keyValue in projectBootConfigEntries)
            {
                if (string.IsNullOrWhiteSpace(keyValue.Value))
                    config.AddKey(keyValue.Key);
                else
                    config.Set(keyValue.Key, keyValue.Value);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Ensure at least one valid target/device for buildTarget is discoverable before launching.
  2. Resolve the underlying per-target failures logged before this rethrow.
  3. For headless/server targets, confirm the deployment endpoint is configured and reachable.

Example fix

/* no source edit */
// before: launch with no discoverable target for buildTarget -> UnityException
// after: register/discover the target (pair device, start emulator, configure deploy host)
// then retry the launch
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure a valid target is discoverable for buildTarget before the launch flow
if (DeploymentTargets.Count(buildTarget) == 0)
    throw new InvalidOperationException($"No valid launch target for {buildTarget}; connect one first.");

Try / catch

try { var launches = PostprocessBuildPlayer.LaunchBuild(buildTarget, ...); }
catch (UnityException ex) when (ex.Message.Contains("Could not find any valid targets"))
{ Debug.LogError($"Connect a device/emulator for {buildTarget}. {ex.Message}"); }

Prevention

When it happens

Trigger: The deployment/launch flow for buildTarget catches NoTargetsFoundException (see error 110) and rethrows as UnityException with the target name, in the outer Launch flow returning the launches list.

Common situations: Same root cause as 110 (no connected/compatible device or emulator for the target), but reached in the code path that returns `launches`; common on platforms requiring a discovered runtime target (mobile, console, cloud).

Related errors


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