Reputation:
So, I'm working on one large existing company project, where things are old / deprecated and I'm trying to improve it step by step.
Right now I'm trying to update JDK version from Java 1.8 to Java 11. So I made changes from Android Studio preference settings.
Also I made this changes as well: https://developer.android.com/studio/releases/gradle-plugin#java-11
About my project:
targetSDKVersion: 30
Android Studio: Latest stable release
Project codeing: 50% code Java and 50% code Kotlin
So, when I made above 2 change and sync the project, it got successfully sync and when I try to run this this exception is coming.
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3137)
at java.base/java.lang.Class.getConstructor0(Class.java:3342)
at java.base/java.lang.Class.newInstance(Class.java:556)
Execution failed for task ':app:kaptPlaystoreDebugKotlin'.
> Internal compiler error. See log for more details
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptPlaystoreDebugKotlin'
NOTE: playstoreDebug is a build variant name.
Upvotes: 3
Views: 576
Reputation: 66
Answer: Upon upgrading from java8 to java11 there are some libraries that have been removed. If one wants to use them they need to be specifically added as dependencies.
This question has already been answered:
Replacements for deprecated JPMS modules with Java EE APIs
Add these dependencies into your pom/gradle:
Gradle:
compile('javax.xml.bind:jaxb-api:2.3.0')
compile('javax.activation:activation:1.1')
compile('org.glassfish.jaxb:jaxb-runtime:2.3.0')
Pom:
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0-b170201.1204</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.0-b170127.1453</version>
</dependency>
Upvotes: 3