领域 Android 无法解析符号 'SyncUser'
Realm Android Cannot resolve symbol 'SyncUser'
每当我尝试导入下面的 类 时,我都会收到“无法解析符号”错误。
io.realm.ObjectServerError;
io.realm.SyncCredentials;
io.realm.SyncUser;
但当我尝试导入时却没有
io.realm.RealmQuery;
io.realm.RealmResults;
io.realm.Realm;
我已经添加了
realm{
syncEnabled = true
}
在我的应用程序中 build.gradle 但它仍然显示相同的错误。
这是我的应用程序 build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
realm{
syncEnabled = true
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.ktoon"
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
这是我的项目build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "io.realm:realm-gradle-plugin:10.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我错过了什么?
10.0.0 中的 API 有许多重大更改。其中,SyncUser更名为io.realm.mongodb.User
。有关完整列表,请参阅 https://github.com/realm/realm-java/blob/master/CHANGELOG.md#1000-2020-10-15
每当我尝试导入下面的 类 时,我都会收到“无法解析符号”错误。
io.realm.ObjectServerError;
io.realm.SyncCredentials;
io.realm.SyncUser;
但当我尝试导入时却没有
io.realm.RealmQuery;
io.realm.RealmResults;
io.realm.Realm;
我已经添加了
realm{
syncEnabled = true
}
在我的应用程序中 build.gradle 但它仍然显示相同的错误。
这是我的应用程序 build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
realm{
syncEnabled = true
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.ktoon"
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
这是我的项目build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "io.realm:realm-gradle-plugin:10.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我错过了什么?
10.0.0 中的 API 有许多重大更改。其中,SyncUser更名为io.realm.mongodb.User
。有关完整列表,请参阅 https://github.com/realm/realm-java/blob/master/CHANGELOG.md#1000-2020-10-15