Daniel Wilson
Daniel Wilson

Reputation: 19824

The following options were not recognized by any processor: '[kapt.kotlin.generated, room.incremental]'

:app:kaptDebugKotlin
w: warning: The following options were not recognized by any processor: '[kapt.kotlin.generated, room.incremental]'

Why am I getting this? I am using Room in a multi module project.

Shared libraries module: api "androidx.room:room-runtime:$room_version" api "androidx.room:room-ktx:$room_version" api "androidx.room:room-rxjava2:$room_version"

App module:

kapt "androidx.room:room-compiler:$room_version"

Gradle.properties

kapt.incremental.apt=true

Build.gradle defaultConfig includes these compile options:

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

Upvotes: 15

Views: 15224

Answers (3)

I had this issue before: what did I do?

First, in build.gradle file in the object called defaultConfig I have to delete:

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

I have to replace:

implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"

With:

// Room components
def room_version = "2.2.5"
implementation "android.arch.persistence.room:runtime:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
kaptAndroidTest "android.arch.persistence.room:testing:$room_version"

// Lifecycle components
def archLifecycleVersion = "2.2.5"
implementation "android.arch.lifecycle:extensions:$archLifecycleVersion"
kapt "android.arch.lifecycle:compiler:$archLifecycleVersion"

Second, in gradle.properties I add:

kapt.incremental.apt=true
kapt.use.worker.api=true
android.lifecycleProcessor.incremental=true

See related problem in other stack overflow page about this configuration.

Upvotes: 0

Michal Reiter
Michal Reiter

Reputation: 31

While I agree that missing kapt in module was the original problem in IDE.

  • "androidx.room:room-compiler:${roomVersion}"

There can be other one in CLI, which you can see with verbose warnings:

Current JDK version 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12 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+.warning: The following options were not recognized by any processor: '[kapt.kotlin.generated, room.incremental]'[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).

Upvotes: 3

Kaushik Burkule
Kaushik Burkule

Reputation: 884

This type of problem can occure with a multi-module project that has been added to room. For such a project the problem was caused by adding the RoomDatabase derived class to a library module, but configuring the build.gradle of app module.

The solution is to configure the build.gradle of the module that contains the RoomDatabase derived class.

  • In the build.gradle file in the dependencies{} section add the dependency for the room compiler.
kapt "android.arch.persistence.room:compiler:$room_version"

Note that for java based project use below code

annotationProcessor "android.arch.persistence.room:compiler:$room_version"

Upvotes: 8

Related Questions