I made a 2d Game on Unity. But when I try "Build and Run" on Android, the below are the errors shown. I don't understand how to debug this or what to search on Google. Can anyone suggest/tell what to look for or how to solve this? Thank you.
Error 1
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
UnityEngine.GUIUtility:ProcessEvent (int,intptr) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
Error 2
CommandInvokationFailure: Failed to update Android SDK package list.
/home/jitesh/3d/Unity/2019.4.22f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager --list
stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
]
stdout[
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, System.Boolean updateCommand, System.String errorMsg, System.String toolsDir, System.String[] warningsToIgnore) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.AndroidSDKTools.ListComponentsVersions () (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.SDKManager.UpdatePackagesList () (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.SDKManager.HighestVersionInstalled (UnityEditor.Android.SDKManager Component tool) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK SDKToolsDetector.GetVersion () (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK SDKComponentDetector.Detect (System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK SDKComponentDetector detector) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d76da2c9a45b4b02b93f56ae560b1d44>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
Error 3
Build completed with a result of 'Failed' in 3 seconds (3266 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
Error 4
UnityEditor.BuildPlayerWindow BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002b3] in /home/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:194
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /home/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
UnityEngine.GUIUtility:ProcessEvent (int,intptr) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
Any suggestion is appreciated. Thank you.
CodePudding user response:
I've had to deal with this error quite a few times. It is due to the JAVA_HOME
path variable not being properly set. You can either manually set it to the proper path, or force Unity to reset it.
To have Unity reset the PATH variables, go to Edit -> Preferences -> External Tools
. On this tab, un-check all of these boxes:
Once un-checked, close Unity, re-open it, and then check all of them again. Try building once everything is checked - it should build without errors.