导入一个已有工程时build失败,gradle task ':app:compileDebugJavaWithJavac' failed,报错如下:
> Task :app:compileDebugJavaWithJavac FAILED
Gradle may disable incremental compilation as the following annotation processors are not incremental: databinding-compiler-3.4.0.jar
(androidx.databinding:databinding-compiler:3.4.0).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run a
nnotation processing in a separate task and make compilation incremental.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> javax/xml/bind/JAXBException
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java
:205)
......
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.instantiateProcessor(AnnotationProcessingCompileTask
.java:137)
......
网上搜索该问题,在https://segmentfault.com/a/1190000020028624和https://segmentfault.com/q/1010000020030377中找到了问题原因解决方法,问题原因是javax.xml.bind不在jdk 9+的默认类路径上,所以找不到这些类,降低使用的jdk版本就可以解决此问题。