Android build error: Unable to load 'javax.xml.bind.jaxbexception
Asked Answered
E

9

60

I am a beginner in Android. I am not able to resolve this error in Android Studio. Whenever I run my application this error occurs. How do I fix it?

Error: Unable to load class 'javax.xml.bind.JAXBException' Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
  • In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Estipulate answered 22/8, 2018 at 4:47 Comment(0)
C
77

This is my solution

Update Gradle build tool version in project-level Gradle.

dependencies {
    classpath 'com.android.tools.build:gradle:7.1.2'
}

And then Android Studio will download and change your gradle-wrapper.properties file.

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

Sync project, everything is OK.

Carouse answered 27/5, 2021 at 9:56 Comment(2)
This is the right answerJameejamel
Thanks. It worked for me. I had cloned an older project and I was using 'com.android.tools.build:gradle:3.5.3' and gradle-5.4.1-all.zip earlier with Android Studio Chipmunk 2021.2.1 Patch 1Levator
D
24

My problem was resolved when I changed the JDK for each of my Android SDKs:

Project Structure -> Platform Settings\SDKs -> Android API xx Platform -> Change "Java SDK" to 1.8

This resolved the problem;

Also change that the Project SDK to 1.8.

enter image description here enter image description here

If the problem is not resolved, Please try to run IDE under JDK 8.

Decussate answered 8/4, 2020 at 21:32 Comment(1)
As I checked in Android studio (bumble bee version-2021.1.2), JDK location was moved to Gradle Settings. So, one can update JDK version either by going to Project Structure > Click on the Gradle Setting link or following this: File > Settings > Gradle JDKWhaley
M
13

This might be too late but maybe some one needs to know the reason:

If you updated android studio to v4.2 and this happened, its because it is build in java 11

You have two options:

  1. change JDK path manually in: Project Structure -> SDK Location

  2. you should update your gradle setting use these two versions or above them:

classpath 'com.android.tools.build:gradle:4.0.0' distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

I hope i could save some one's time

Marcelenemarcelia answered 31/5, 2021 at 13:11 Comment(0)
C
8

Also you can Update your gradle version in project level gradle

classpath 'com.android.tools.build:gradle:4.x.x'

and fixed this issue.

Cortege answered 21/5, 2021 at 5:21 Comment(0)
N
0

install java 8, and set your JDK path with java 8

File- > Project structure. -> SDK location -> JDK Location

for mac os:

/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home
Nessie answered 19/6, 2021 at 14:24 Comment(0)
L
0

First check your gradle-wrapper.properties distributionUrl value and update with latest version of gradle.

distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

enter image description here

Levenson answered 10/7, 2021 at 13:6 Comment(0)
T
0

this is the one of the possible solutions, It was worked for me.

In app build file, add the options javaCompileOptions{ ... }

android {
    …
    defaultConfig {
    …
        //add this options
        javaCompileOptions { 
            annotationProcessorOptions { 
                includeCompileClasspath = true 
            } 
        }
    }
    …
}
Toiletry answered 22/7, 2021 at 2:48 Comment(0)
I
0

Just upgrade the Gradle version then it will fix the problem

Interracial answered 8/2, 2022 at 10:50 Comment(0)
S
0

This is what I did: I updated the Gradle build tool version in the project-level Gradle configuration. By ensuring that my Gradle build tool version was up-to-date, I resolved the issue and successfully built my Android project without encountering the JAXB error.

Scrouge answered 9/5, 2024 at 8:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.