0
\$\begingroup\$

When i am trying to build an apk from unity. Than its show me some error something like this :-

CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. 
E:/DEWA/msgs/Kunal/android-sdk-windows-1.6_r1\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_121\lib\tools.jar;C:\Program Files\Java\jre1.8.0_141\lib\rt.jar;

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)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Build completed with a result of 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


Error building Player: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. 
E:/DEWA/msgs/Kunal/android-sdk-windows-1.6_r1\tools\bin\avdmanager.bat list target -c

stderr[

]
stdout[

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_121\lib\tools.jar;C:\Program Files\Java\jre1.8.0_141\lib\rt.jar;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
]
exit code: 1
\$\endgroup\$
  • \$\begingroup\$ Is java jdk installed? \$\endgroup\$ – Bálint Mar 23 '18 at 12:59
  • \$\begingroup\$ Yes its has been already installed @Bálint \$\endgroup\$ – Kunal Pitale Mar 25 '18 at 12:43
  • \$\begingroup\$ You have to provide us with more info to help you. It says "make sure path for Android SDK is correct", did you install Android SDK? and if so, how? Also says JAVA_HOME is set to an invalid directory, have you installed java? The more details you provide us, the more accurate we can be. The best answer right now is "install android sdk and java, then point JAVA_HOME to the right path", which I suspect doesn't answer your question. \$\endgroup\$ – TomTsagk Jul 6 '18 at 13:56
  • \$\begingroup\$ most of the time its a jdk sk problem. make sure sdk is updated and hast all built and platform tools. make sure jdk is installed and updated and has set its directory to environment variables. this can fix it 99% \$\endgroup\$ – virtouso Aug 9 '18 at 7:17
1
\$\begingroup\$

Try installing older version of the android SDK, I'v seen that it solves this problem to many many people.. including my friends.

\$\endgroup\$

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.