javaandroidandroid-studioandroid-gradle-plugin

warning: The following options were not recognized by any processor: '[room.schemaLocation]'


I got this warning:

warning: The following options were not recognized by any processor: '[room.schemaLocation]'

I've already checked the below links solutions and it seems to be a different problem. I receive the error while working with Android Studio IDE on an Android project. The error popped up after changes to binding variable in xml (changed type from Integer to int due to Unboxing warning and that i actually only require int).

Already checked below solutions:

NetBeans bug 233098

getting-android-studio-gradle-and-android-annotations-working-together

annotationprocessor-option-not-recorgnized-by-any-processor


Solution

  • I had a similar problem with a multi-module project that I added room to. For my project the problem was caused by adding my RoomDatabase derived class to a library module, but configuring the build.gradle of my app module.

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

    There are 3 main pieces to the solution:

    1. Your RoomDatabase derived class (AppDatabase in this example)

    @Database(entities = arrayOf(SomeWidgetEntity::class), version = 50)
    abstract class AppDatabase : RoomDatabase() {
      //your code goes here
    }
    

    2. In the build.gradle file of the module that contains AppDatabase add the following to the defaultConfig{} section.

    defaultConfig {
    
        javaCompileOptions {
            annotationProcessorOptions {
            arguments = ["room.schemaLocation":
                         "$projectDir/schemas".toString()]
            }
        }
    
    }
    

    3. In the SAME build.gradle file in the dependencies{} section add the dependency for the room compiler.

    dependencies {
    
        //for kotlin based projects (where $room_version is the version of room you're using)
        kapt "androidx.room:room-compiler:$room_version"
        //for java based projects
        annotationProcessor "androidx.room:room-compiler:$room_version"
    
    }