Programming Tutorials

gradle build failed Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

By: Ignatius in Android Tutorials on 2023-04-03  

The error \"Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema\" occurs when you are using a Java version that does not include the required class definition for javax/xml/bind/annotation/XmlSchema.

This issue typically arises when using Java versions 9 or higher, as the javax.xml.bind package has been removed from the Java SE platform since Java 9. Therefore, if you are using Java 9 or higher, you may encounter this error when building a Gradle project that relies on the javax.xml.bind package.

To resolve this error, you need to add the javax.xml.bind module to your Gradle build configuration. Here are the steps you can take:

  1. Open your Gradle build file (usually named build.gradle) and add the following lines:
    dependencies {
        implementation 'javax.xml.bind:jaxb-api:2.3.0'
    }
    

    This will add the jaxb-api dependency to your project.

  1. If you are using Java 9 or higher, you need to add the javax.xml.bind module to the module-info.java file. Open the module-info.java file in your project and add the following lines:
    module your.module.name {
        requires java.xml.bind;
    }
    

    Make sure to replace your.module.name with the name of your module.

  1. Save your changes and rebuild your project. The javax.xml.bind module should now be included in your build and the error should be resolved.





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Android )

gradle build failed Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

'adb' is not recognized as an internal or external command, operable program or batch file.

Android Send SMS and Make a phone call in Android Application

Keep your android phone awake while debugging

compileSdkVersion vs buildToolsVersion in app/build.gradle

Gradle, npm, react-native - How are they related?

Emulator: glTexImage2D: got err pre :( 0x506 internal 0x8058 format 0x1908 type 0x1401

Emulator: WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***

./gradlew assembleDebug '.' is not recognized as an internal or external command, operable program or batch file.

Performing Streamed Install adb: failed to install app buildoutputsapkdebugapp-debug.apk: Exception occurred while executing 'install': android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

Is it safe to delete userdata-qemu.img userdata-qemu.img.qcow2 files

adb.exe: no devices/emulators found

How to start the Android emulator

Get Location of an android phone programmatically

Getting Started with Android

Latest Articles (in Android)

Keep your android phone awake while debugging

compileSdkVersion vs buildToolsVersion in app/build.gradle

gradle build failed Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

Gradle, npm, react-native - How are they related?

Emulator: glTexImage2D: got err pre :( 0x506 internal 0x8058 format 0x1908 type 0x1401

Emulator: WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***

./gradlew assembleDebug '.' is not recognized as an internal or external command, operable program or batch file.

'adb' is not recognized as an internal or external command, operable program or batch file.

Performing Streamed Install adb: failed to install app buildoutputsapkdebugapp-debug.apk: Exception occurred while executing 'install': android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

Is it safe to delete userdata-qemu.img userdata-qemu.img.qcow2 files

adb.exe: no devices/emulators found

How to start the Android emulator

Get Location of an android phone programmatically

Getting Started with Android

Solution to error: unable to open connection to server due to security error

Related Tutorials

Keep your android phone awake while debugging

compileSdkVersion vs buildToolsVersion in app/build.gradle

gradle build failed Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

Gradle, npm, react-native - How are they related?

Emulator: glTexImage2D: got err pre :( 0x506 internal 0x8058 format 0x1908 type 0x1401

Emulator: WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***

./gradlew assembleDebug '.' is not recognized as an internal or external command, operable program or batch file.

'adb' is not recognized as an internal or external command, operable program or batch file.

Performing Streamed Install adb: failed to install app buildoutputsapkdebugapp-debug.apk: Exception occurred while executing 'install': android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

Is it safe to delete userdata-qemu.img userdata-qemu.img.qcow2 files

adb.exe: no devices/emulators found

How to start the Android emulator

Get Location of an android phone programmatically

Getting Started with Android

Solution to error: unable to open connection to server due to security error