Error: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
Task ‘:app:kaptNormalDebugKotlin’ execution failed.
Internal compiler error. Refer to the log for more information.
在项目的build.gradle
文件中,需要调整Gradle插件的版本:
dependencies {
// 原先版本为3.5.3
classpath 'com.android.tools.build:gradle:4.0.0'
}
完成上述更改后,同步项目可能会出现如下提示:
Minimum supported Gradle version is 6.1.1. Your current version is 5.4.1.
Please update the project's Gradle settings to use version 6.1.1 or later.
Modify the Gradle version in the Gradle wrapper to 6.1.1 and re-import the project.
Open Gradle wrapper properties via Gradle settings.
根据提示,点击确认进行修改。具体步骤是在gradle-wrapper.properties
文件中更新Gradle版本:
distributiOnBase=GRADLE_USER_HOME
distributiOnUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
distributiOnPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
// 旧版本配置
// zipStorePath=wrapper/dists
// distributiOnUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
移除或注释掉旧的Gradle版本配置,并保存更改。最后,重新同步项目以应用新的设置。
参考资料:
This is an unexpected error. Please report this issue along with the contents of the idea.log file to the development team for further analysis.