在会议室数据库中添加另一个表时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在会议室数据库中添加另一个表时出错相关的知识,希望对你有一定的参考价值。
我已经在我的应用程序中使用会议室数据库。现在,我已将项目迁移到androidX,因此依赖项已更改。
现在添加表并尝试运行项目时,出现多个文件错误:
error: cannot find symbol class BR
这是我的模特班:
@Keep
@Entity
public class Notification
private String title;
private String body;
public Notification(String title, String body)
this.title = title;
this.body = body;
public String getTitle()
return title;
public void setTitle(String title)
this.title = title;
public String getBody()
return body;
public void setBody(String body)
this.body = body;
这是我的NotificationDao类:
public abstract class NotificationDao
@Insert(onConflict = REPLACE)
public abstract void insert(Notification notification);
@Query("DELETE FROM Notification")
public abstract void deleteAll();
以下是用于迁移的代码:
static final Migration MIGRATION_1_2 = new Migration(1, 2)
@Override
public void migrate(SupportSQLiteDatabase database)
database.execSQL("CREATE TABLE IF NOT EXISTS Notification (`title` TEXT, `body` TEXT)");
;
我将版本从1增加到2。
我也在构建中添加了它。
Room.databaseBuilder(
application,
MyDatabase.class,
Configuration.DB_NAME
).addMigrations(MyDatabase.MIGRATION_1_2).build();
app.gradle是:
buildscript
repositories
maven url 'https://maven.fabric.io/public'
dependencies
classpath 'io.fabric.tools:gradle:1.+'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories
maven url 'https://maven.fabric.io/public'
android
compileSdkVersion 29
defaultConfig
minSdkVersion 21
targetSdkVersion 29
versionCode 211990017
versionName "2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// Write out the current schema of Room
javaCompileOptions
annotationProcessorOptions
arguments = ["room.schemaLocation": "$projectDir/schemas".toString(),]
vectorDrawables.useSupportLibrary = true
project.archivesBaseName = "xxxx";
multiDexEnabled true
externalNativeBuild
cmake
cppFlags "-std=c++11 -fexceptions"
arguments "-DANDROID_TOOLCHAIN=clang",
"-DANDROID_STL=c++_shared",
"-DANDROID_PLATFORM=android-21"
sourceSets
main
jniLibs.srcDirs = ['src/main/jniLibs']
externalNativeBuild
cmake
path "CMakeLists.txt"
signingConfigs
release
storeFile file("keystores/xxxx")
storePassword "xxxx"
keyAlias "xxxx"
keyPassword "xxxx"
lintOptions
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
buildTypes
release
minifyEnabled false
shrinkResources false
proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
debug
minifyEnabled false
shrinkResources false
proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
dataBinding
enabled true
buildToolsVersion '28.0.3'
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
flavorDimensions "environment"
productFlavors
development
applicationId "com.emproto.xxxx"
resValue "string", "content_provider", "com.xxx.xxxx.fileprovider"
production
applicationId "com.xxxx"
resValue "string", "content_provider", "com.xxxx.fileprovider"
splits
// Configures multiple APKs based on ABI.
abi
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "arm64-v8a", "armeabi-v7a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk true
ext.abiCodes = ['x86': 1, 'x86_64': 2, 'armeabi-v7a': 3, 'arm64-v8a': 4]
import com.android.build.OutputFile
android.applicationVariants.all variant ->
variant.outputs.each output ->
def baseVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (baseVersionCode != null)
output.versionCodeOverride = Integer.valueOf(baseVersionCode + variant.versionCode)
ext
retrofitVersion = '2.3.0'
daggerVersion = '2.11'
supportLibVersion = '28.0.0'
googleLibVersion = '16.0.1'
frescoLibVersion = '2.0.0'
moEngageVersion = '9.8.02'
dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
/*Dagger 2 is a fully static and compile time dependency injection framework*/
implementation "com.google.dagger:dagger:$daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
implementation 'javax.annotation:jsr250-api:1.0'
/*LiveData and ViewModel*/
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
/*
annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
*/
/*Room*/
implementation 'androidx.room:room-runtime:2.2.3'
annotationProcessor 'androidx.room:room-compiler:2.2.3'
// Java8 support for Lifecycles
implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
/*Retrofit*/
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
/*For loading images from network*/
implementation "com.facebook.fresco:fresco:$frescoLibVersion"
implementation "com.facebook.fresco:imagepipeline-okhttp3:$frescoLibVersion"
/*For the left menu*/
implementation 'com.yarolegovich:sliding-root-nav:1.1.0'
/*For the typing indicator*/
implementation 'com.github.channguyen:adv:1.0.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
/*For Graphs */
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
/*For firebase push notifications */
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-core:16.0.6"
/*For Database debugging */
// debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
/*For S - Health */
implementation files('libs/s-health/samsung-health-data-v1.3.0.jar')
implementation files('libs/s-health/sdk-v1.0.0.jar')
/*For Google-Fit */
implementation "com.google.android.gms:play-services-fitness:$googleLibVersion"
implementation "com.google.android.gms:play-services-auth:$googleLibVersion"
/*Circular floating action bar*/
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
// For animated GIF support
implementation "com.facebook.fresco:animated-gif:$frescoLibVersion"
/*Circular seekbar - Feelings*/
implementation 'com.github.JesusM:HoloCircleSeekBar:v2.2.2'
/*Circular Layout - Feelings*/
implementation 'com.github.andreilisun:circular-layout:1.0'
/*For offline log synchronization*/
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
/*Wheel picker - RecordCholesterol*/
implementation 'com.weigan:loopView:0.1.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar')
transitive = true;
/*Image Cropper - Profile Fragment*/
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
/*PDF Viewer - Prescription/Report */
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
api 'com.thedesigncycle.ui:views:0.3.1'
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation files('libs/omron/jp.co.omron.healthcare.omoron_connect.wrapper-1.3.jar')
implementation 'com.appsee:appsee-android:+'
implementation 'com.github.florent37:viewtooltip:1.1.6'
implementation 'com.asksira.android:cameraviewplus:0.9.5'
implementation 'me.zhanghai.android.materialratingbar:library:1.3.1'
implementation 'com.priyankvex:smarttextview:1.0.1'
implementation 'com.github.flipkart-incubator:android-inline-youtube-view:1.0.3'
implementation 'com.github.varunest:sparkbutton:1.0.6'
implementation 'io.branch.sdk.android:library:3.2.0'
//foo transitions in trel home(doctor names)
implementation "com.andkulikov:transitionseverywhere:1.8.1"
//AppsFlyer
implementation 'com.appsflyer:af-android-sdk:4.10.3'
implementation 'com.android.installreferrer:installreferrer:1.0'
//picasso image loading lib
implementation 'com.squareup.picasso:picasso:2.5.2'
//Facebook analytics dependency
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
//Moengage dependency
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.moengage:moe-android-sdk:$moEngageVersion"
apply plugin: 'com.google.gms.google-services'
如何解决错误?
答案
未在模型类中添加主键会导致此问题。我认为Android Studio方面应该提供有关会议室数据库的更具体的错误消息。
以上是关于在会议室数据库中添加另一个表时出错的主要内容,如果未能解决你的问题,请参考以下文章
使用 postgres_fdw 创建外部表时翻译主机名时出错