We're trying to improve the build times of our multi-module Android app and we've reached the point where we tried to enable incremental KAPT annotation processing compilation.
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 (inside each module that uses Room):
kapt {
arguments {
arg("room.incremental", "true")
}
}
However, while trying to benchmark the build times using gradlew assemble -scan
command, Gradle throws the following error:
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).
I've tried to set Open JDK 11 as the default JDK for the project in the Project Structure window, but it didn't work, it complained about it not being JDK 8. Any ideas what's wrong with this setup?
you will need to using JDK embedded with AS to solve this. make sure to use AS 3.5 above. On project structure -> SDK location make sure jdk is pointed to jdk shipped with AS. /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home Then you will need to restart your AS.
If you running from terminal make sure $JAVA_HOME contains correct path.
I guess Android studio not supporting JDK 11 yet. I also tried to use latest JDK 8 (231, which AS 3.5 using 202) but it causing this issue.
When compiling, it showed me a warning:
Current JDK version 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+.Note: 1 Wrote GeneratedAppGlideModule with: [][WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).
Then I downloaded JDK 8 (8u261) from the Oracle site (it requies registration, so look for a direct link).
Installed it, changed JAVA_HOME
system variable to a new path:
Then recompiled the app. Even restart wasn't required.
UPDATE
After a month I again saw the same warning. Then read the accepted answer and found Java embedded with Android Studio: C:\Program Files\Android\Android Studio\jre
.
File > Project Structure...
, then SDK Location
, and in the field JDK location
wrote that path. Restarted AS.
Go to Project Structure > SDK Location, then Gradle settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With