Fix Unity Android Build Error: ADB server failed! Xamarin & Unity ADB conflict solution. Close Xamarin in Visual Studio!
Today I was trying to create a new Unity Android Build for one of my Games, and I faced this error :
CommandWithNoStdoutInvokationFailure: Unable to start ADB server. Please make sure the Android SDK is installed and is properly configured in the Editor. See the Console for more details.
at UnityEditor.Android.Command.RunWithShellExecute (System.String command, System.String args, System.String workingdir, System.String errorMsg) [0x00060] in <59b231ad19bf42f6b72bf2546a9b9393>:0
at UnityEditor.Android.ADB.StartServer () [0x00013] in <59b231ad19bf42f6b72bf2546a9b9393>:0
at UnityEditor.Android.ADB.Run (System.String[] command, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0000b] in <59b231ad19bf42f6b72bf2546a9b9393>:0
at UnityEditor.Android.AndroidDeploymentTargetsExtension.GetKnownTargets (UnityEditor.DeploymentTargets.IDeploymentTargetsMainThreadContext context, UnityEditor.ProgressHandler progressHandler) [0x0001d] in <59b231ad19bf42f6b72bf2546a9b9393>:0
at UnityEditor.DeploymentTargets.DeploymentTargetManager.GetKnownTargets () [0x00001] in <4dfeb7acf9f44dd0adc2a4f68156471c>:0
at UnityEditor.Android.AndroidBuildWindowExtension+<>c__DisplayClass31_0.<SpawnFetchTargetsThread>b__0 () [0x00002] in <59b231ad19bf42f6b72bf2546a9b9393>:0
After restarting Unity some times, Plugging in and out my Android Device and some research on the Internet, I was finally able to Solve the problem.
What was causing it was a conflict between the ADB.exe from Xamarin for Visual Studio and the ADB.exe from Unity itself. When trying to create the Unity Build, at the same time, I had another instance of Visual Studio Open with an Xamarin Project.
I just closed the Visual Studio Xamarin Project and then IT WORKED! I was able to generate the Android Build for Unity again! =)
So remember, when trying to generate a build for Unity Android, NEVER keep an instance of Visual Studio with a Xamarin Project open at the same time, and everything should work as expected!
Have you had the same problem and this article helped you? Please leave a comment here comment!
Thank you and see you next time! Peace and Live Longer and Prosper! π
FAQ
What actually causes the "Unable to start ADB server" error in Unity?
It's caused by a conflict between two different adb.exe processes trying to control the same Android debugging connection — in this case, the ADB.exe bundled with Xamarin for Visual Studio and the ADB.exe used by Unity itself.
Do I need to reinstall the Android SDK to fix this error?
No. Even though the error message suggests checking your Android SDK installation, in this case the SDK was fine — the real fix was closing the conflicting Visual Studio Xamarin project, not touching the SDK setup.
How do I prevent this ADB conflict from happening again?
Simply avoid having a Visual Studio instance with a Xamarin project open at the same time you're building an Android project in Unity — closing the Xamarin project before building resolved the issue.
Is restarting Unity or reconnecting my Android device enough to fix it?
Not reliably — restarting Unity and unplugging/replugging the device didn't solve the problem in this case; closing the conflicting Visual Studio Xamarin project was what actually fixed it.
Comments
Have a question, or found an issue with the code? Drop a comment below — I read and reply to every one.