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;
  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值