What is the problem? I fixed the SDK bug of that time, Unity 5.6.4p2. (before that, on the newest version, I compiled everything quietly on Android) On Windows, everything compiled, but on Android - no.

Full list of errors:

enter image description here

CommandInvokationFailure: Failed to build apk. E:/Downloads/jdk\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/Eloren/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:567) at SDKMain.main(SDKMain.java:130) Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:177) at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446) at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:422) at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:362) at UnityApkBuilder.<init>(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:436) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 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.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.HostView:OnGUI() 

I know you do not understand the same way as I do, but maybe who faced.

  • You are using a non-standard sun,misc.BASE64Encoder class sun,misc.BASE64Encoder . And this class can not be found when building apk. - Rafael Osipov
  • What to do? What is this class and where is it? - Yaroslav Smirnov
  • Do you explicitly use this class in your code? - Rafael Osipov
  • If you are using it explicitly, use the standard class java.util.Base64 - Rafael Osipov instead.
  • I just do not even understand what it is about - Yaroslav Smirnov

1 answer 1

Most likely, the path to the JDK (Java Development Kit) is not registered in the settings of your project and when building, Unity simply cannot find the required classes. In this case, sun.misc.Base64 .

Check the settings of the Android SDK and JDK in your project and list the necessary paths if required.