Schema export directory is not provided to the annotation processor so we cannot export the schema.

安卓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.
未向批注处理器提供架构导出目录,因此无法导出架构。你可以提供room.schemaLocation注释处理器参数或将exportSchema设置为false。

解决方法
1、在build gradle中添加(推荐)

    android {
        ...
        defaultConfig {
            ...
            javaCompileOptions {
                annotationProcessorOptions {
                    arguments = ["room.schemaLocation":
                                 "$projectDir/schemas".toString()]
                }
            }
        }
    }

2、在数据库注解中添加exportSchema = false(不推荐)

@Database(entities = {entity.class}, version = 4, exportSchema = false)


原因:
在编译时,Room 会将数据库的架构信息导出为 JSON 文件(默认exportSchema = true导出架构)。要导出架构,请在 build.gradle 文件中设置 room.schemaLocation 注释处理器属性(设置将json存放的位置)。

我们没有设置exportSchema = false不导出架构或者没有设置架构导出的位置,所以构建错误

参考:

迁移 Room 数据库  |  Android 开发者  |  Android Developers
————————————————
版权声明:本文为CSDN博主「怪大大」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_40733723/article/details/106566119

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The Little MongoDB Schema Design Book, covers the fundamentals off Schema design with MongoDB, as well as several useful Schema design patters for your applications. I wrote this book to be a helpful and concise guide to MongoDB Schema design, as well as a repository to look up specific MongoDB Schema patterns. This book came around, due to my experiences teaching people about using MongoDB for application development. It tries to cover essential information that you can apply to your own applications. We cover a lot of different aspects of Schema Design in this book. These include. Schema Basics including one to one, one to many and many to many relationships Embedding versus linking Bucketing Strategy Understanding the MongoDB MMAP and WiredTiger storage engine MongoDB Indexes The Metadata Schema Pattern Time Series Schema Pattern Queues Schema Pattern Nested Categories Schema Pattern Account Transactions Schema Pattern Shopping Cart Schema Pattern with and without product reservation A Theater Ticket Reservation Schema Pattern An Embedded Array Cache Schema Pattern An Internationalization Schema Pattern Sharding The book aims to provide developers with a deep but concise understanding of how to efficiently work with MongoDB. Table of Contents Introduction Schema Basics One-To-One (1:1) One-To-Many (1:N) Many-To-Many (N:M) MMAP Storage Engine WiredTiger Storage Engine Indexes Sharding Schema Design Queue Topics Metadata Materialized Path Category Hierarchy Shopping Cart with Product Reservation Shopping Cart with No Product Reservation Theater Reservation Account Transactions Time Series Array Slice Cache Internationalization

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值