How to Fix “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema” When Installing Android SDK

How to Fix "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema" When Installing Android SDK

6 June 2024 Stephan Petzl Leave a comment Tech-Help

Encountering the error java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema while installing Android SDK tools can be frustrating. This issue often arises due to incompatibilities between the Android SDK tools and certain versions of Java. Here, we provide a step-by-step guide to resolve this issue effectively.

Steps to Resolve the Issue

1. Download the Latest Android SDK Command-line Tools

One of the most straightforward solutions is to download the latest Android SDK Command-line Tools. Here’s how you can do it:

  1. Open Android Studio.
  2. Navigate to Preferences > Appearance & Behavior > System Settings > Android SDK > SDK Tools.
  3. Check the box next to Android SDK Command-line Tools (latest).
  4. Click Apply and wait for the installation to complete.

For Android Studio Giraffe | 2022.3.1 Patch 1, find these settings under File > Settings, then in the left panel, navigate to Languages & Frameworks > Android SDK and finally select the SDK Tools.

2. Update Your PATH Environment Variable

After installing the latest command-line tools, you need to add the new tools to your PATH. This can be done by updating your .bashrc, .zshrc, or a similar profile file:

export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin

3. Re-run Flutter Doctor

If you are using Flutter, re-run the following commands to ensure that all licenses are accepted:

flutter doctor --android-licenses

Accept all the licenses by typing y when prompted.

Alternative Solutions

Downgrade Java Version

If the above steps do not resolve your issue, consider downgrading your Java version to Java 8. Here are the commands for macOS using Homebrew:

brew cask uninstall java  # uninstall java9
brew tap homebrew/cask-versions
brew cask install java8  # install java8

Then, update your Android SDK:

brew install --cask android-sdk


Following these steps should help you resolve the java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema error when installing the Android SDK tools. Ensuring that you have the latest command-line tools and the correct Java version are key steps to avoid this issue.

Streamline Your Mobile App Testing with Repeato

While resolving development issues is crucial, ensuring the quality of your mobile applications is equally important. Repeato, our no-code test automation tool for iOS and Android, can help you create, run, and maintain automated tests for your apps efficiently. Leveraging computer vision and AI, Repeato makes it easy to edit and run tests quickly, allowing you to focus on creating a great product.

With Repeato, you can even delegate test automation tasks to non-technical colleagues or QA teams, freeing up your time for more critical development tasks. Learn more about how Repeato can enhance your mobile app testing process by visiting our documentation.

Like this article? there’s more where that came from!