我们正在尝试改进我们的多模块Android应用程序的构建时间,我们已经尝试启用增量KAPT注释处理编译。
- Android Studio版本:v3.5.2
- Room版本:v2.2.1
- Gradle版本:v5.4.6
- Android Gradle插件版本:v3.5.2
- Kotlin版本:v1.3.50
gradle.properties:
org.gradle.daemon=true
org.gradle.caching=true
org.gradle.parallel=true
kapt.incremental.apt=true
kapt.use.worker.api=true
kapt.include.compile.classpath=false
android.databinding.incremental=true
build.gradle(在每个使用Room的模块内):
kapt {
arguments {
arg("room.incremental", "true")
}
}
然而,当尝试使用gradlew assemble -scan
命令来基准测试构建时间时,Gradle会抛出以下错误:
warning: Current JDK version 1.8.0_201-b09 has a bug (https://bugs.openjdk.java.net/browse/JDK-8007720) that prevents Room from being incremental. Consider using JDK 11+ or the embedded JDK shipped with Android Studio 3.5+.
ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1
[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).
我尝试在“项目结构”窗口中将Open JDK 11设置为项目的默认JDK,但它没有起作用,并且抱怨它不是JDK 8。这个设置出了什么问题?
gradlew assemble -scan
,请确保您的JAVA_HOME
环境变量也指向您在 Android Studio 中设置的相同 JDK11。 - DanyBoricua