Error:
Invalid command android
UnityEditor.HostView:OnGUI()
CommandInvokationFailure:
Unable to list target platforms. Ple
Easier solution: set the environment variable USE_SDK_WRAPPER=1, or hack tools/android.bat to add the line "set USE_SDK_WRAPPER=1". This prevents android.bat from popping up a "y/n" prompt, which is what's confusing Unity.
In my case, I was trying to build and get APK for an old Unity 3D project (so that I can play the game in my Android phone). I was using the most recent Android Studio version, and all the SDK packages I could download via SDK Manager in Android Studio. SDK Packages was located in
C:/Users/Onat/AppData/Local/Android/Sdk And the error message I got was the same except the JDK (Java Development Kit) version "jdk-12.0.2" . JDK was located in
C:\Program Files\Java\jdk-12.0.2 And Environment Variable in Windows was JAVA_HOME : C:\Program Files\Java\jdk-12.0.2
After 3 hours of research, I found out that Unity does not support JDK 10. As told in https://forum.unity.com/threads/gradle-build-failed-error-could-not-determine-java-version-from-10-0-1.532169/ . My suggestion is:
1.Uninstall unwanted JDK if you have one installed already. https://www.java.com/tr/download/help/uninstall_java.xml
2.Head to http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
3.Login to/Open a Oracle account if not already logged in.
4.Download the older but functional JDK 8 for your computer set-up(32 bit/64 bit, Windows/Linux etc.)
5.Install the JDK. Remember the installation path. (https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/)
6.If you are using Windows, Open Environment Variables and change Java Path via Right click My Computer/This PC>Properties>Advanced System Settings>Environment Variables>New>Variable Name: JAVA_HOME>Variable Value: [YOUR JDK Path, Mine was "C:\Program Files\Java\jdk1.8.0_221"]
7.In Unity 3D, press Edit > Preferences > External Tools and fill in the JDK path (Mine was "C:\Program Files\Java\jdk1.8.0_221").
8.Also, in the same pop-up, edit SDK Path. (Get it from Android Studio > SDK Manager > Android SDK > Android SDK Location.)
9.If needed, restart your computer for changes to take effect.
I solved the problem by uninstalling JDK 9.
The issue is due to incompatibility of unity with latest Android build tools. For MacOS here's a one liner that will get it working for you:
cd $ANDROID_HOME; rm -rf tools; wget http://dl-ssl.google.com/android/repository/tools_r25.2.5-macosx.zip; unzip tools_r25.2.5-macosx.zip
For Mac OS Users :
Go to your Android SDK folder and delete the tools folder (I recommend you to make a copy before deleting it, in case this solution does not solve the problem for you)
Then download the tools folder here :
http://dl-ssl.google.com/android/repository/tools_r25.2.5-macosx.zip
You can find all tools zip version here :
https://androidsdkoffline.blogspot.fr/p/android-sdk-build-tools.html
Then unzip the download file and place it in the Android sdk folder.
Hope it helps
Linux Users:
cp -r Android AndroidUnity
cd AndroidUnity/Sdk
rm -rf tools
wget http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
unzip tools_r25.2.5-windows.zip
In Unity preferences change to this newly created sdk folder.