Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"
The NoClassDefFoundError
for javax/xml/bind/annotation/XmlSchema
could be fixed by introducing JAXB. It is not included by default in Java 11+. For Maven projects, add:
Gradle projects require:
These dependencies should resolve the classpath issue for the Android SDK installation.
Getting Android SDK ready
Set up PATH for Android SDK Tools
After installing Android SDK Command-line Tools (latest), add the path of these tools to PATH
environment variable.
Keeping it Java 8
The Android SDK may not play nicely with Java 9+. Switch back to Java 8 for the android sdk compatibility.
Uninstall Java 9 (or above), install Java 8:
Accepting licenses
Run flutter doctor --android-licenses
and hit 'y' when prompted.
All licenses should be accepted post installation or updates of Android tools.
Guide to setup environment
Acquaint yourself with Android SDK Tools
Know your Android SDK directory path and SDK Tools in Android Studio:
File > Settings > Languages & Frameworks > Android SDK > SDK Tools
Ensure all necessary SDK tools are installed and visible here.
Taming Java with options
For Java 8, you may need to export additional Java options:
Persist these settings by adding them to your .bashrc
or .zshrc
file.
Verify your installation
Confirm successful installation by running the sdkmanager
command. It responds by listing the installed packages in your SDK, else displays the error.
In case of errors, create a repositories.cfg
file in .android
directory. Sometimes, errors are due to missing cfg files.
Was this article helpful?