I have just started using android development and trying to use Room library. Since yesterday I am facing this warning message
w: [kapt] Incremental a
From Room documentation:
"Room has the following annotation processor options...room.incremental: Enables Gradle incremental annotation proccesor."
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"]
}
}
}
}
Be sure to update the room version to 2.2.x or higher.
Just add this line to you gradle.properties:
kapt.incremental.apt=true
There is a bug in kotlin-gradle-plugin version of 1.3.50 as @Necrontyr mentioned. Just downgrade the kotlin_version in build.gradle(Project) to 1.3.41.
Here is a list of things you can do to fix this and significantly decrease your build times while you're at it.
In your build.gradle
(module) file:
android {
...
defaultConfig {
...
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
arg("room.incremental", "true")
arg("room.expandProjection", "true")
}
}
}
...
}
In your gradle.properties
file:
kapt.incremental.apt=true // enabled by default on 1.3.50+
kapt.use.worker.api=true // faster builds
kapt.include.compile.classpath=false // near instant builds when there are few changes
android.databinding.incremental=true
android.lifecycleProcessor.incremental=true
//add your specific library if it supports incremental kapt
A lot of the other answers here cover up the error or disable incremental processing instead of actually making it work the way you want.
You can enable incremental processing for your specific library in the gradle.properties
file. Just add these settings, or whichever one matches the library that throws the error:
android.databinding.incremental=true
android.lifecycleProcessor.incremental=true
I'm using AndroidX, but It guess it's the same for android.arch.lifecycle
. For me it simply helped replacing this:
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
... with this:
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
So if you're using android.arch.lifecycle
it might have the same effect replacing this:
kapt "android.arch.lifecycle:compiler:$lifecycle_version"
... with this:
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
Be aware that this only works if you're using Java 8 and that you also should remove OnLifecycleEvent annotations for LifecycleObserver classes and let those observers implement DefaultLifecycleObserver instead.
Changing to this method is also recommended in the build.gradle
depencies shown here.