Android Room 报 Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide room.schemaLocation annotation processor argument OR set exportSchema to false.

一、使用 annotationProcessor

如果用的 annotationProcessor "androidx.room:room-compiler:xxx",在使用Room Module的build.gradle文件添加:

android {

...

defaultConfig {

...

javaCompileOptions {

annotationProcessorOptions {

arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]

}

}

}

}

二、使用 kapt

如果用的 kapt "androidx.room:room-compiler:xxx",在使用Room Module的build.gradle文件添加:

android {

...

defaultConfig {

...

kapt {

arguments {

arg("room.schemaLocation", "$projectDir/schemas")

}

}

}

}

三、使用 ksp

如果用的 ksp "androidx.room:room-compiler:xxx",在使用Room Module的build.gradle文件添加:

android {

...

defaultConfig {

...

ksp {

arg('room.schemaLocation', "$projectDir/schemas")

}

}

}

四、把 exportSchema 设为 false

如果以上都不行,就直接把 exportSchema 设为 false 吧,这功能不要也罢。

@Database(

...

exportSchema = false

)

abstract class AppDatabase : RoomDatabase() {

}

参考阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: