我收到了这个警告:
警告:以下选项未被任何处理器识别:'[room.schemaLocation]'
我已经检查了以下链接的解决方案,这似乎是一个不同的问题。 我在 Android 项目上使用 Android Studio IDE 时收到错误。在更改 xml 中的绑定(bind)变量后弹出错误(由于拆箱警告,类型从 Integer 更改为 int,而我实际上只需要 int)。
已检查以下解决方案:
getting-android-studio-gradle-and-android-annotations-working-together
最佳答案
我在添加 room 的多模块项目中遇到了类似的问题。对于我的项目,问题是由于将我的 RoomDatabase
派生类添加到库模块,但配置了我的应用程序模块的 build.gradle
。
解决方案是配置包含RoomDatabase
派生类的模块的build.gradle
。
解决方案有 3 个主要部分:
1. 您的 RoomDatabase
派生类(本例中为 AppDatabase
)
@Database(entities = arrayOf(SomeWidgetEntity::class), version = 50)
abstract class AppDatabase : RoomDatabase() {
//your code goes here
}
2. 在包含 AppDatabase
的模块的 build.gradle
文件中,将以下内容添加到 defaultConfig{}/
部分。
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
3. 在 SAME build.gradle
文件的 dependencies{}
部分添加依赖项room 编译器。
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"
}
关于java - 警告 : The following options were not recognized by any processor: '[room.schemaLocation]' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45979736/