错误:


解决方法一:
以下代码添加到 build.gradle —> android{ … } —> defaultConfig{ … }
参考博客:Android Studio3.0 Error:Execution failed for task ‘:app:javaPreCompileDebug’ 错误
android {
defaultConfig {
...
//添加如下配置
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
...
}
}

解决方法二:
以下代码添加到:build.gradle —> dependencies { … } (添加依赖那块地方)
参考链接:Unable to load class ‘javax.xml.bind.JAXBException‘.
添加后可能出现的问题:(报 kapt有问题,改为 —> annotationProcessor)
// 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"
}

方法三
1、gradle-wrapper.properties —> distributionUrl(更换本地的版本)
2、build.gradle —> classpath(更换本地的版本)
其他解决方法:
注:出现此问题的原因有几种,同一个异常,不一定是同一个解决方案,以上方法没解决的可参考以下博客
1、Android Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’ 解决方案
2、真正解决方案:java.lang.ClassNotFoundException: javax.xml.bind.JAXBException