最近在搞room数据库 保存h5发来的数据
在编译时报了一个错误 如下所示
警告: 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.
未向批注处理器提供架构导出目录,因此无法导出架构。您可以提供room.schemaLocation注释处理器参数,也可以将exportSchema设置为false。
通过google在中国的官方 我们查到关于这个错误的答案
Android迁移 Room 数据库
还有一种方法也可以 就是把exportSchema设置为false(不推荐)
@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
public abstract class MovieDatabase extends RoomDatabase {
}
原因:
在编译时,Room 会将数据库的架构信息导出为 JSON 文件(默认exportSchema = true导出架构)。要导出架构,请在 build.gradle 文件中设置 room.schemaLocation 注释处理器属性(设置将json存放的位置)。
我们没有设置exportSchema = false不导出架构或者没有设置架构导出的位置,所以构建错误!



