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!).
 * 

* 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. *

* {@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,问题,随笔,android)