15
: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.

  • Kotlin version: 1.3.50
  • AGP: 3.5.0
  • Room: 2.2.0-rc01

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"]
        }
    }
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
  • 1
    Where is room annotation processor is added? – Kaushik Burkule Oct 03 '19 at 10:04
  • Thanks Kaushik I think you've pointed me in the right direction. I edited the answer to reflect that those dependencies are specified in one module, and an app module features the annotation processor. Possibly I am specifying the flags in modules which do not use the processor – Daniel Wilson Oct 03 '19 at 10:10
  • i think the solution is to configure the build.gradle of the module that contains the RoomDatabase derived class. – Kaushik Burkule Oct 03 '19 at 10:16
  • Yes this is the key, so even if a module has the dependencies and annotation processor but doesn't use them, it seems to produce this warning. If you leave this as an answer I will accept, maybe it will help someone :) – Daniel Wilson Oct 03 '19 at 10:43
  • Yes sure! I will add these as an answer. – Kaushik Burkule Oct 03 '19 at 10:44

3 Answers3

7

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"
Kaushik Burkule
  • 816
  • 1
  • 12
  • 27
3

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).

0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186