目录

AndroidxjectPackRoom集成报错

目录

http://image.catbro.cn/b3add008abbf.png

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.

根据提示我们有两种解决方案:

  • 1、给RoomDatabase设置exportSchema注解为false。

    @Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
    

-2 、在项目中gradle中通过 annotationProcessorOptions 注解,为room.schemaLocation指定schemas的子文件夹。

  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.ocrapp"
          minSdkVersion 16
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
          //指定room.schemaLocation生成的文件路径
          javaCompileOptions {
              annotationProcessorOptions {
                  arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
              }
          }
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }

  }