0

I am getting this error when building the library: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

This is what I get when I get java versions on my Mac:

java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode) 

The project is open source here: https://github.com/NickM-27/LinkPreview

I have tried cleaning as well as clearing and re-downloading from git to no avail

Please let me know what other information you need.

1 Answer 1

1

Do you have multiple Java versions installed on your machine? kapt has a bug which does not pickup the correct Java version defined as default in compileOptions {} block in Gradle.

Kapt is most likely using recent version of Java which split Jaxb class into separate module since Java version 9.

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

Until the Kapt bug (I don't have a link) is fixed, uninstall unneeded Java versions or force kapt to pickup the correct version by adding this:

kapt { javacOptions { option("-source", "8") option("-target", "8") } 

Reference: https://github.com/google/dagger/issues/1449

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

1 Comment

Yep that's it, unfortunately I need the newer java version so this code should do the trick. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.