{"record":{"id":"f3796e533a41822e","repo":"Unity-Technologies/UnityCsReference","slug":"could-not-find-any-valid-targets-to-launch-on-for","errorCode":null,"errorMessage":"Could not find any valid targets to launch on for {0}","messagePattern":"Could not find any valid targets to launch on for (.+?)","errorType":"exception","errorClass":"UnityException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs","lineNumber":302,"sourceCode":"                        throw new NoTargetsFoundException(\"Could not launch build\");\n                    }\n                });\n\n                taskManager.Run();\n            }\n            catch (DeploymentOperationFailedException e)\n            {\n                UnityEngine.Debug.LogException(e);\n                EditorUtility.DisplayDialog(e.title, e.Message, \"OK\");\n            }\n            catch (DeploymentOperationAbortedException)\n            {\n                System.Console.WriteLine(\"Deployment aborted\");\n            }\n            catch (NoTargetsFoundException e)\n            {\n                Debug.LogException(e);\n                throw new UnityException(string.Format(\"Could not find any valid targets to launch on for {0}\", buildTarget));\n            }\n\n            return launches;\n        }\n\n        [RequiredByNativeCode]\n        static public void UpdateBootConfig(BuildTarget target, BootConfigData config, BuildOptions options)\n        {\n            IBuildPostprocessor postprocessor = ModuleManager.GetBuildPostProcessor(target);\n            if (postprocessor != null)\n                postprocessor.UpdateBootConfig(target, config, options);\n\n            foreach (var keyValue in projectBootConfigEntries)\n            {\n                if (string.IsNullOrWhiteSpace(keyValue.Value))\n                    config.AddKey(keyValue.Key);\n                else\n                    config.Set(keyValue.Key, keyValue.Value);","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Ensure at least one valid target/device for buildTarget is discoverable before launching.","Resolve the underlying per-target failures logged before this rethrow.","For headless/server targets, confirm the deployment endpoint is configured and reachable."],"exampleFix":"/* no source edit */\n// before: launch with no discoverable target for buildTarget -> UnityException\n// after: register/discover the target (pair device, start emulator, configure deploy host)\n// then retry the launch","handlingStrategy":"try-catch","validationCode":"// Ensure a valid target is discoverable for buildTarget before the launch flow\nif (DeploymentTargets.Count(buildTarget) == 0)\n    throw new InvalidOperationException($\"No valid launch target for {buildTarget}; connect one first.\");","typeGuard":null,"tryCatchPattern":"try { var launches = PostprocessBuildPlayer.LaunchBuild(buildTarget, ...); }\ncatch (UnityException ex) when (ex.Message.Contains(\"Could not find any valid targets\"))\n{ Debug.LogError($\"Connect a device/emulator for {buildTarget}. {ex.Message}\"); }","preventionTips":["Register/discover the runtime target before launching.","Surface the underlying per-target failures logged just before this rethrow."],"tags":["launch","deployment","no-targets","build-pipeline"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}