How to get rid of Incremental annotation processing requested warning?

Solution 1:

Just add this line to you gradle.properties:

kapt.incremental.apt=true

Solution 2:

The real problem is that incremental processing makes things faster, but if any of the annotation processors are non incremental, none of them will be actually processed in that way.

What's the purpose of incremental processing?

From version 1.3.30+, incremental processing allowed modules not to be entirely processed again each time a change occurs, giving the build process a better performance:

The main areas of focus for this release have been around Kotlin/Native, KAPT performance, as well as improvements for IntelliJ IDEA.

From Kotlin documentation:

Annotation processors (see JSR 269) are supported in Kotlin with the kapt compiler plugin. In a nutshell, you can use libraries such as Dagger or Data Binding in your Kotlin projects.

How to fix Room Incremental Processing?

Room incremental annotation processor is disabled by default. This is a known issue and it's described here. They intend to fix it on version 2.2.0. You can just wait for the update or you can enable that to get rid of the warning by setting:

in gradle.properties file:

kapt.incremental.apt=true

(optional steps)

to allow databinding to be incremental:

android.databinding.incremental=true

for faster builds:

kapt.use.worker.api=true

if only a few changes are made, the build time greatly decreases:

kapt.include.compile.classpath=false

(back to the subject)

in your project build.gradle, add the necessary dependencies (Groovy):

dependencies {
    ...
    implementation "androidx.room:room-runtime:2.2.0-rc01"
    annotationProcessor "androidx.room:room-compiler:2.2.0-rc01"
}

and

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.incremental":"true"]
            }
        }
    }
}

Kotlin DSL version:

dependencies {
    ...
    implementation("androidx.room:room-runtime:2.2.0-rc01")
    kapt("androidx.room:room-compiler:2.2.0-rc01")
}

and

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = mapOf("room.incremental" to "true")
            }
        }
    } 
}

October 9, 2019

androidx.room:room-*:2.2.0 is released.

Gradle Incremental Annotation Processor: Room is now a Gradle isolating annotation processor and incrementability can be enabled via the processor option room.incremental.

Latest update:

For the newest Kotlin DSL versions, please use

    javaCompileOptions {
        annotationProcessorOptions {
            arguments["room.incremental"] = "true"
        }
    }

Solution 3:

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.

Solution 4:

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.

Solution 5:

Enable Kapt Incremental annotation processing requeste

Use Kotlin 1.3.31 or newer Kotlin 1.3.30 released

In your android kotlin project gradle.properties file

# Enable Kapt Incremental annotation processing requeste
kapt.incremental.apt=true

# Enable android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC)
android.databinding.incremental=true

# Decrease gradle builds time 
kapt.use.worker.api=true

# turn off AP discovery in compile path, and therefore turn on Compile Avoidance
kapt.include.compile.classpath=false

# Enable In Logcat to determine Kapt
kapt.verbose=true