I can not understand what the matter is and what exactly it wants from me ¯_ (ツ) _ / ¯ Here is the copy-paste of the entire text of the error, straight from Unity. If you need to provide something else to solve the problem, please write. The latest SDK and JDK are installed. NDK did not install.

CommandInvokationFailure: Failed to build apk. E:/Android/JDK\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/Android/AndroidSDK\tools" -Dfile.encoding=UTF8 -jar "E:\Unity3D\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: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: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.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.HostView:OnGUI() 

What I tried to do to solve the problem (I did not understand the mistake, I acted on this at random):

  1. Reinstalled java.
  2. Allocated more memory for it.
  3. Pumped up more SDK versions for all versions of Android.
  • What kind of plugins? And the empty project bildit? - Xumera_hZ
  • Unfortunately, an empty project also does not save. No plugins installed. - W0lfEnd

2 answers 2

You have a problem because the class sun/misc/BASE64Encoder is not located

This is how I remember the result of some kind of patent war between Oracle and someone else, in general, if you don’t go into details, replace

 import sun.misc.BASE64Encoder; 

on

 import java.util.Base64 

or

 import org.apache.commons.codec.binary.Base64; 

Read more here.

Update

As an option, if Unity pulls this class from somewhere else from its guts, then go to either Java 8 or even Java 7

  • Thank you very much, now I will try to apply your advice :) - W0lfEnd
  • Do not forget, please, answer, helped or not. - DarkOwl 1:09 pm
  • Having a little rummaged, I didn’t understand exactly where to change these lines, since I don’t use Java in my project at all. And here, as I understand it, the solution for Java code. - W0lfEnd
  • I and understood that it stretches from guts of Unity. This is what I assumed in the answer in Java <9 there is no such problem - Barmaley

The installation of an earlier JDK (in this case JDK 8.161, was 9+) + helped install Java of the same version. Thanks to everyone who participated in this issue.