W3docs

Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"

The java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema error can occur if the required Java XML Binding (JAXB) classes are not present on the classpath.

The java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema error can occur if the required Java XML Binding (JAXB) classes are not present on the classpath.

To fix this error, you need to include the JAXB API in your project. The JAXB API was included in the Java SE Development Kit (JDK) as part of the Java Standard Edition (SE) prior to JDK 11. If you are using a newer JDK that does not include the JAXB API, you can download the JAXB API separately and include it in your project.

To include the JAXB API in your project, you need to add the following dependencies to your build file (e.g., build.gradle):

dependencies {
    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
    runtimeOnly group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.1'
}

Replace 2.3.1 with the version of the JAXB API that you want to use.

Note: If the error occurs specifically during the Android SDK installation, the installer uses the system JDK. You can resolve it by setting ANDROID_JAVA_HOME to a JDK 8 installation, or by updating to a newer version of Android Studio that bundles its own JDK.

I hope this helps. Let me know if you have any questions.