Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 877
Noy Oliel Avatar asked Aug 31 '17 10:08

Noy Oliel


2 Answers

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 "android.arch.persistence.room:compiler:$room_version"
    //for java based projects
    annotationProcessor "android.arch.persistence.room:compiler:$room_version"

}
like image 144
mukwux Avatar answered Sep 20 '22 18:09

mukwux


I tried deleting the following from the application build.gradle file:

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

Then, I ran "rebuild", added the same segment again and the error disappeared. I don't know why it solved the problem but it did.

Note: Rebuilding\cleaning without removing the above gradle definition didn't work for me so it must be removed and added again before rebuilding.

like image 21
Noy Oliel Avatar answered Sep 16 '22 18:09

Noy Oliel