android studio 4.2时出现,
Unable to load class 'javax.xml.bind.JAXBException'.
This is an unexpected error. Please file a bug containing the idea.log file.
谷歌查看,好像与JDK版本有关,要用JDK8才行,下载JDK8后,发现项目无法更改adk路径,file->project structure->SDK Location->JDK Locatio无法更改,提示“choose a valid jdk 11 project”。这个问题不知道是什么原因。
使用JDK 9+时,您需要添加JAX-B依赖项。对于Android Studio用户,您需要将其添加到您app内的build.gradle
的dependencies {}
块中:
// Add missing dependencies for JDK 9+
if (JavaVersion.current().ordinal() >= JavaVersion.VERSION_1_9.ordinal()) {
// If you're using @AutoValue or any libs that requires javax.annotation (like Dagger)
compileOnly 'com.github.pengrad:jdk9-deps:1.0'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
// If you're using Kotlin
kapt "com.sun.xml.bind:jaxb-core:2.3.0.1"
kapt "javax.xml.bind:jaxb-api:2.3.1"
kapt "com.sun.xml.bind:jaxb-impl:2.3.2"
// If you're using Java
annotationProcessor "com.sun.xml.bind:jaxb-core:2.3.0.1"
annotationProcessor "javax.xml.bind:jaxb-api:2.3.1"
testAnnotationProcessor "com.sun.xml.bind:jaxb-core:2.3.0.1"
testAnnotationProcessor "javax.xml.bind:jaxb-api:2.3.1"
}
加了上述代码后,可以编译。
神奇的是,JDK Locatio的值也可以更改了。具体原因不明