- Home /
How do I solve CommandInvokeFailure?
Hello. The problems have started yesterday, when I couldn't build my android game because unity couldn't "list target platforms". I looked up the solution in the internet and it really helped me. But then unity started saying: "CommandInvokationFailure: Failed to build apk." I looked for the solution again (link) but it didn't work.
Here is the whole report:
CommandInvokationFailure: Failed to build apk.
C:/Program Files/Java/jdk-9\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/Turar/AppData/Local/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[ Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at SDKMain.main(SDKMain.java:129) Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder at com.android.sdklib.internal.build.SignedJarBuilder.(SignedJarBuilder.java:177) at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446) at com.android.sdklib.build.ApkBuilder.(ApkBuilder.java:422) at com.android.sdklib.build.ApkBuilder.(ApkBuilder.java:362) at UnityApkBuilder.(UnityApkBuilder.java:214) at UnityApkBuilder.main(UnityApkBuilder.java:34) ... 5 more Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ... 11 more ] stdout[
] exit code: 1 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.WaitingForProc essToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.HostView:OnGUI()
What should I do?
P.S: I also thought that the problem is with my keystore but it's not
P.P.S: I have the latest SDK version and unity5.6.0f3
Thanks in advance!
Hey there!
I have the exact same problem, did you fix it?
Hi,
Unfortunately, no. The only possible solution I see, as of now, is to reinstall everything :(.
But if you find one, could you please notify me?
Thank you.
Did you accidentally download the 32 but version of the sdk while building 64, or vice versa?
Hello! I downloaded the 64bit version of the sdk. The latest one.
Prior to unity 2017, 64 bit was experimental. Did you check that you build for 64 bit on player settings for android?
Answer by $$anonymous$$ · Sep 27, 2017 at 09:22 PM
Ok, whoever reads it, I got the solution.
After hours of searching the internet I read that sometimes Unity doesn't work properly with the last versions of JDK. So I downgraded my JDK from 9 to 8 and installed 86bit version. Now it works fine.
Thanks for taking the time to post your solution after hours of troubleshooting!
Dude, thanks, I searched hours... Finally I started to actually read the error, then searched this line:
Exception in thread "main" java.lang.reflect.InvocationTargetException
And found your AWESO$$anonymous$$E answer.
Answer by abarrak · Sep 26, 2017 at 03:56 PM
My concern is that there is an article that talks about don't use the sun package in a java project so why is unity doing that? http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612135622im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
unable convert classes into dex format 0 Answers
Admob Build Error ? 0 Answers
Java error when building 1 Answer
Failed to find Build Tools revision 29.0.0 - Android Builds 4 Answers