Android build CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.
After an update of the latest versions of Android SDK it start to throw an error while trying to build an android app. Here is the stacktrace:
Error building Player: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/hardartcore/Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
stderr[
Error:Invalid command android
]
stdout[
]
exit code: 64
and
CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/hardartcore/Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
stderr[
Error:Invalid command android
]
stdout[
]
exit code: 64
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.HostView:OnGUI()
hello, in this video i explain how to resolve this problem https://youtu.be/UaQe-fns$$anonymous$$4w
Answer by jgwinner · Mar 08, 2017 at 08:06 PM
Upgrading to the latest does not work; that's what caused my problem :) They removed a feature and called it "Deprecated" without any warnings (this is not deprecation, it's removal).
The fix is to rename the "Tools" directory in the Android SDK.
Go to Unity, got to Edit->Preferences, then "External Tools"
Note where the Android SDK is located.
Go there, and rename the "Tools" folder to Tools-XXXX (replace XXX with version, or just call it Tools-Old). This is so you have a backup. You could just delete the folder.
Then, download this file:
http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
Unzip it to the "Android SDK" location you found in the first step. Make sure it's "Tools".
Then, exit and reload Unity - build. It should work.
Also, thanks to @Vladimir-Niakhai, the MacOS version is at:
https://developer.android.com/studio/index.html
and look for "tools_r25.2.3-macosx.zip"
Credit to this thread on stack overflow: http://stackoverflow.com/questions/42538433/not-finding-android-sdk-unity and https://code.google.com/p/android/issues/detail?id=235455#makechanges
== John ==
thank you so much! I spent the last hour trying to understand what I was doing wrong (since I installed unity + android sdk) several times previously - never expected it to get harder/ for there to be a new "trick"!
Go there, and rename the "Tools" folder to Tools-XXXX (replace XXX with version).
I do not understand what should be on the place of XXXX. Can someone show example of tools dir name?
anything. Its just so that the newly downloaded folder doesn´t override the old folder because its the same name. U can delete it or rename it so that u have a backup.
PixlShrk nailed it - it's just so you have a backup, but you don't even really need the old "Tools" folder. You could even name it Tools-Old or Tools-Bad. The name doesn't actually matter as you won't be using it. I changed my answer slightly to make it more obvious.
Answer by ginoadriano · Mar 14, 2017 at 02:49 PM
Any solution for this on Mac OSX?
You can found "tools_r25.2.3-macosx.zip" at the bottom of that page https://developer.android.com/studio/index.html
Thanks! I figured out how to edit my answer and gave you credit :)
Answer by Knertified · Mar 03, 2017 at 05:12 PM
I fixed this problem by going into Android Studio, Uninstalling SDK Build tools, restarting Android Studio and upgrading to the latest build tools.
FYI, $$anonymous$$y solution above was for macOS. I didn't have to rename any folders.
Answer by batchku · Apr 08, 2017 at 11:00 PM
I am having the same problem. I'm using Unity 5.6f3 and trying to build with the latest SDK (Android 7.1.1), on windows 10.
I've tried @jgwinner's suggestion of replacing the 'tools' folder in the android SDK with the one from: http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
Still same error.
I have also tried @Knertified's suggestion of uninstalling and reinstalling the SDK Tools with Android Studio's SDK Manager. Still the same error.
Are you all succeeding in building with Unity 5.6f3 for Android now? What exact version of the SDK are you using and where did you get it (from a link, or using the Android Studio SDK Manager?)
Answer by batchku · Apr 08, 2017 at 03:34 AM
I am having the same problem. I'm using Unity 5.6f3 and trying to build with the latest SDK (Android 7.1.1), on windows 10.
I've tried @jgwinner's suggestion of replacing the 'tools' folder in the android SDK with the one from: http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
Still same error.
I have also tried @Knertified's suggestion of uninstalling and reinstalling the SDK Tools with Android Studio's SDK Manager. Still the same error.
Are you all succeeding in building with Unity 5.6f3 for Android now? What exact version of the SDK are you using and where did you get it (from a link, or using the Android Studio SDK Manager?)
I was using 5.6.0.b4, and the steps I posted fixed it. I got the r25.2.5 from the zip posted; check out the stack overflow link, they may have more detail.
I'm happily building Android apps.
Did you replace the folder, or did you rename the folder, then create a new folder called 'tools' and install tools_r25.2.5-windows from the zip? Not sure if it makes a difference, but it's a thought. I'd make sure none of the newer files are in that directory. You're putting something older over the top of newer stuff (that broke the build), so just copying things on top might not work.
Uninstalling and reinstalling never fixed it, as the latest disabled a 'deprecated' function because someone doesn't understand the difference between 'removed' and 'deprecated'. It went from there to not there. Deprecated functions are supposed to be left in place, with a warning, until all tool chain users have a chance to remove it. This got removed all at once (see my links) and has broken a bunch of stuff.
== John ==
Oh I am using unity 5.6.0f3 and I tried every suggested solution but no success. Did you solved the issue?? Can I ask you how you solved it????
I would like to know if you could fix the problem. I'm having the same issue that you have/had. Please, tell me that you have found the solution!
Your answer
Follow this Question
Related Questions
I can't catch Unity build errors via script 0 Answers
WebGL build failing Unity v5.2 0 Answers
Build error,How do you prevent this errorwhen you build? 0 Answers
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors 0 Answers
Build crashes on load 0 Answers