Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException after updating to Android Studio 4.2

Google just release Android Studio 4.2 stable. I updated my AS from 4.1 to 4.2. Now I am getting this error. It's showing error in data binding.

Caused by: java.util.ServiceConfigurationError: javax.annotation.processing.Processor: android.databinding.annotationprocessor.ProcessDataBinding Unable to get public no-arg constructor
        at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1200)
        at kotlin.collections.CollectionsKt___CollectionsKt.toMutableList(_Collections.kt:1233)
        at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1224)
        at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.doLoadProcessors(ProcessorLoader.kt:80)
        at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors(ProcessorLoader.kt:45)
        at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:42)
        ... 28 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        ... 34 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
        ... 34 more
like image 844
iamanbansal Avatar asked May 06 '21 02:05

iamanbansal


3 Answers

Android Studio 4.2.0 and more now comes with Java 11.0.8 shipped and will use it by default which cases this error in deprecated libraries.

The solution is simple, you need to change it to java (JDK) 1.8 in the menu File > Project Structure > JDK Location

image

Notices that Android Studio lower than 4.2.0 comes with java 1.8 already

like image 50
Dannark Avatar answered Oct 18 '22 03:10

Dannark


By doing the following steps I solved this problem without replacing JDK with JAVA 8.

Step 1 : Update the distributionUrl to https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip in your gradle-wrapper.properties

Step 2: Update your gradle tool classpath to 'com.android.tools.build:gradle:4.2.1' in your root buid.gradle

like image 27
Dentor Avatar answered Oct 18 '22 04:10

Dentor


I had same issue, and I alrady solved. I found that Android studio 4.2 will make the JDK update to Java11, it will cause error what you described.

You can delete the Java11 JDK and replace by Java8 (/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home).

Also you can uninstall the Android Studio, and reinstall it.

like image 8
jeffrohu Avatar answered Oct 18 '22 02:10

jeffrohu