18

Alright so I'm trying to build my React-Native app using Android Studio. I first ran into this error when building:

Failed to install the following Android SDK packages as some licences have not been accepted.
   build-tools;29.0.2 Android SDK Build-Tools 29.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: C:\Users\jaspe\AppData\Local\Android\Sdk

When figuring that out I came across this answer which told me to accept the licenses. However in trying to do so I got the following error:

C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager --licenses
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

To resolve which I found this post. I don't use brew, but I tried the second answer. It didn't work, sadly enough. Then I found out I didn't have a JDK installed, so I did that. But with the newest JDK installed I still get an exception:

C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat -licenses
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.xml.bind not found

And now I'm not sure what to do anymore. I found an answer explaining I needed to edit my project settings, but I think this doesn't apply to my project, and honestly I'm in a bit over my head. Does someone have experiences with these errors, and can help me fix them? I've spent the whole morning trying to figure this out, I'd expected building a runnable .APK as a demo would be easier...

3
  • Did you add JAVA_HOME to PATH? Commented Jul 1, 2021 at 12:47
  • Oh, yes I did. Forgot to add. JAVA_HOME: C:\Program Files\Android\Android Studio\jre Commented Jul 1, 2021 at 12:58
  • that's a path of jre. JAVA_HOME should point to the JDK. Commented Jul 2, 2021 at 6:03

2 Answers 2

56

You are using the wrong sdkmanager, tools directory has been deprecated

Open Android Studio and install the latest command-line tools:

enter image description here

This will create this folder in your Android SDK:

...\Android\Sdk\cmdline-tools\latest\bin

Now use the sdkmanager which is inside the bin directory to accept all the licenses:

C:\Users\jaspe\AppData\Local\Android\Sdk\cmdline-tools\latest\bin>sdkmanager.bat --licenses

Sign up to request clarification or add additional context in comments.

7 Comments

How can be done through CLI?
Found it, the sdkmanager tool has been moved to /cmdline-tools/latest/bin from /tools/bin
After searching all other answers on stackoverflow. This one is the only solution, Cheers!
Finally! The XmlSchems issue was fixed after so many years.
Thanks @PhiliposD. I was executing the sdkmanager file from /tools/bin. This give me the error as the OP says. Then I searched for the cmdline-tools/latest/bin and execute the file from there. And all licenses are acepted.
|
1

@MatPag's answer has the solution I needed, but it took me a while to recognise it. Posting this answer for a specific case incase it helps someone else.

I was trying to setup Unreal Engine v4.25.4 when I encountered this error. I needed to run a batch script that came with Unreal Engine located at:

C:\Program Files\Epic Games\UE_4.25\Engine\Extras\Android\SetupAndroid.bat

which produced the error:

Android Studio Path: C:\Program Files\Android\Android Studio Android Studio SDK Path: C:\Users\brianb\AppData\Local\Android\Sdk Using sdkmanager: C:\Users\brianb\AppData\Local\Android\Sdk\tools\bin\sdkmanager.bat Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156) at com.android.repository.api.SchemaModule.(SchemaModule.java:75) at com.android.sdklib.repository.AndroidSdkHandler.(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 Update failed. Please check the Android Studio install. Press any key to continue . . .

Even after I located the sdkmanager.bat script and executed it according to MatPag's answer, my AndroidSetup.bat script was failing.

Eventually I realised the AndroidSetup.bat was trying to call the sdkmanager.bat from the wrong location.

I edited the AndroidSetup.bat file (line 61) as follows to correct the path:

:: set SDKMANAGER=%STUDIO_SDK_PATH%\tools\bin\sdkmanager.bat set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.