How to get rid of Incremental annotation processing requested warning?

后端 未结 13 987
一生所求
一生所求 2020-12-04 08:27

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

13条回答
  •  孤街浪徒
    2020-12-04 08:36

    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"
            }
        }
    

提交回复
热议问题