5

I'm trying to update to gradle 5.4 and thus JDK 11 but I'm having errors when building:

 Task :app:compileDesarrolloDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDesarrolloDebugJavaWithJavac'.
> javax/xml/bind/JAXBException

I've been searching for some solution and I found that I had to add some dependencies on my app/build.gradle because Java 9+ does not install jre anymore:

compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
compile group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.1'

But I'm still getting the same error:

javax/xml/bind/JAXBException
> javax.xml.bind.JAXBException

org.gradle.api.tasks.TaskExecutionException
: 
Execution failed for task ':app:compileDesarrolloDebugJavaWithJavac'.
Open stacktrace
Caused by: 
java.lang.NoClassDefFoundError
: 
javax/xml/bind/JAXBException
Open stacktrace
Caused by: 
java.lang.ClassNotFoundException
: 
javax.xml.bind.JAXBException
Close stacktrace
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.instantiateProcessor(AnnotationProcessingCompileTask.java:149)
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.setupProcessors(AnnotationProcessingCompileTask.java:108)
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:91)
at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:36)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
...

Full app/build.gradle: https://gist.github.com/vivoconunxino/a68d2011bc1b184a83786a6268533087

Full error: https://gist.github.com/vivoconunxino/1a27586133b34adbbe8314395e6704a1

1
  • Please let me know if any more relevant info is needed, I'll gladly edit the post Commented Jan 30, 2020 at 15:25

2 Answers 2

11

I found this issue as well.

I added the following to my gradle dependencies:

dependencies {
    [...]
    implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
    implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.3'

    annotationProcessor 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
    annotationProcessor 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
    annotationProcessor 'javax.annotation:javax.annotation-api:1.3.2'
}
Sign up to request clarification or add additional context in comments.

3 Comments

Finally the answer which helped me solve the problem. However, I had to remove implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3' to avoid error: D8: Program type already present: javax.activation.MimeTypeParseException, and add: ``` android { ... packagingOptions { exclude 'META-INF/NOTICE.md' exclude 'META-INF/LICENSE.md' } } ``` to avoid: "More than one file was found with OS independent path 'META-INF/LICENSE.md'"
Could you pls show us the way you find the solution?
@lrnrzg I don't remember the details, I may have google'd "com.sun.xml.bind replacement" and found the answer.
2

Note: I'm just trying to make a comment, but do not have enough reputation to make one.

I just ran into this issue today, when attempting to build an Android App with Gradle 6.1.1 (also tried on 5.4.1), and using JDK 11, on macOS 10.15.3 (Catalina).

I fixed this issue by downgrading my JDK, to JDK8, since according to this (How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9), apparently JAXB was removed in JDK 11.

I feel like this is an issue related to a Gradle plugin (possibly com.android.application, or a kotlin plugin), since I built JNI via Gradle with JDK11.

1 Comment

It's not the answer I expected, but in the end I could not fix it in any other way than that. I also had to downgrade the JDK. Weird, it should be possible adding some dependency. For the moment this is the only answer, hope points serve you for commenting next time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.