I'm trying to accept as licenses to use React Native, but it gives the following error:
I'm putting the following command:
$ C:\Android\Sdk\tools\bin\sdkmanager --sdk_root=${ANDROID_HOME} --licenses
Error:
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
Java version:
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment 18.9 (build 11.0.12 7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12 7, mixed mode)
What could this error be and how to solve it?
CodePudding user response:
This is being caused because you're using JDK 11. The class javax.xml.bind.annotation.XMLSchema
is present in JDK 8. So first, downgrade JDK 11 to 8 in your environment variables, and then the problem should be solved.