1
\$\begingroup\$

For some reason, I am unable to test my android program because of this error. Here are some pictures of the errors. This error is not allowing me to test my app on my test Android device, I have tried uninstalling and reinstalling, checking if it is acatually the root folder, everything, PLEASE HELP!

1st error

CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. 
C:/Users/jayso/AppData/Local/Android/sdk\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, Boolean updateCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidSDKTools.ListTargetPlatforms (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
UnityEditor.Android.AndroidSDKTools.GetTopAndroidPlatformAvailable (UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKPlatformDetector.GetVersion (UnityEditor.Android.AndroidSDKTools sdkTools)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Detect (UnityEditor.Android.AndroidSDKTools sdkTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (Int32 minVersion, UnityEditor.Android.PostProcessor.Tasks.SDKComponentDetector detector)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

2nd Error

Error building Player: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. 
C:/Users/jayso/AppData/Local/Android/sdk\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
]
exit code: 1

My Unity preferences

\$\endgroup\$
  • \$\begingroup\$ Not to be condecending, but did you try Google first? I see two answers.unity.com posts, five Stack Overflow posts, and three YouTube videos about this problem. \$\endgroup\$ – Draco18s no longer trusts SE May 2 '18 at 23:58
  • \$\begingroup\$ Yes I've been looking for about 5 hours between yesterday and today none of the soloutions have helped. \$\endgroup\$ – Jayson Meribe May 3 '18 at 1:30
  • 1
    \$\begingroup\$ Then update your question to include what you tried and why those solutions didn't work for you. "PLEASE HELP" is not a problem description \$\endgroup\$ – Draco18s no longer trusts SE May 3 '18 at 4:04
  • \$\begingroup\$ Update or redownload Android SDK \$\endgroup\$ – buffalo94 May 3 '18 at 9:39
  • 1
    \$\begingroup\$ @sonny Unity 2018.1 came out yesterday and they seem to have fixed the issue when I updated unity, Thank you. \$\endgroup\$ – Jayson Meribe May 4 '18 at 2:48
1
\$\begingroup\$

Updating to unity 2018.1 solved the issue

\$\endgroup\$
1
\$\begingroup\$

(EDIT: Updating to Unity 2018.1 fixed the issue for the asker. The below answer is not correct for this case, but it may be relevant for other people with the same error message)

You need to downgrade your JDK version to JDK 8 for now.

There is an active issue on the Unity Issue Tracker for JDK 9.

If this does not solve your issue, you should debug to see if your JAVA_HOME path is set correctly in your PATH variable as your error message suggests. For more details, see this relevant SO post.

\$\endgroup\$
  • 1
    \$\begingroup\$ I checked and I actually have JDK version 1.8 in my Unity preferences. There is a picture I posted on the question showing my preferences. \$\endgroup\$ – Jayson Meribe May 3 '18 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.