Android ROOM编译时提示错误Schema export directory is not provided to the annotation processor so we cannot(
Posted 怪兽N
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android ROOM编译时提示错误Schema export directory is not provided to the annotation processor so we cannot(相关的知识,希望对你有一定的参考价值。
问题
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
.但是能编译通过。
解决
添加@Database
注解中添加exportSchema=false
@Database(entities = {User.class,LoginInfo.class},version = 1,exportSchema=false)
public abstract class UserRoomDataBase extends RoomDatabase {
public abstract UserDao userDao();
public abstract LoginInfoDao loginInfoDao();
}
说明
Schema是数据库的组织和结构,exportSchema指暴露数据库的组织架构到一个文件夹,这个文件夹通过room.schemaLocation指定。Schema记录了数据库的组织和结构,并带有版本信息,所以不适合在发布的app中的文件夹中,而是最好指定到版本控制系统中,默认为true打开状态。所以系统编译是,提醒你。
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.
/**
* You can set the annotation processor argument ({@code room.schemaLocation}) to tell Room to
* export the database schema into a folder. Even though it is not mandatory, it is a good
* practice to have version history of your schema in your codebase and you should commit the
* schema files into your version control system (but don't ship them with your app!).
* <p>
* When {@code room.schemaLocation} is set, Room will check this variable and if it is set to
* {@code true}, the database schema will be exported into the given folder.
* <p>
* {@code exportSchema} is {@code true} by default but you can disable it for databases when
* you don't want to keep history of versions (like an in-memory only database).
*
* @return Whether the schema should be exported to the given folder when the
* {@code room.schemaLocation} argument is set. Defaults to {@code true}.
*/
boolean exportSchema() default true;
以上是关于Android ROOM编译时提示错误Schema export directory is not provided to the annotation processor so we cannot(的主要内容,如果未能解决你的问题,请参考以下文章
Android Room 编译时警告外键中的列不属于索引。这是啥意思?
Android JetPack组件之Room数据库的集成与详解
TypeConverter() 在 Android 中的 Room 出现 TypeConverter 错误时具有私有访问权限
错误:找不到字段的设置器。 - java.util.ArrayList 中的大小 - Room 中的嵌入式 ArrayList 无法编译
Kotlin 注释处理器在将 Room 与 Android Studio 3.0 beta7 一起使用时出现编译时错误