0

Ich habe Code von Realm objectServerExample genommen.Der Android Realm kann das Symbol SyncCredentials, SyncUser, ObjectServerError nicht auflösen. Aber Realm, RealmObject .. Klassen funktionieren gut

SyncCredentials creds = SyncCredentials.usernamePassword(username, password, createUser); 
     SyncUser.Callback<SyncUser> callback = new SyncUser.Callback<SyncUser>() { 
      @Override 
      public void onSuccess(@Nonnull SyncUser user) { 
       progressDialog.dismiss(); 
       onLoginSuccess(); 
      } 

      @Override 
      public void onError(@Nonnull ObjectServerError error) { 
       progressDialog.dismiss(); 
       String errorMsg; 
       switch (error.getErrorCode()) { 
        case UNKNOWN_ACCOUNT: 
         errorMsg = "Account does not exists."; 
         break; 
        case INVALID_CREDENTIALS: 
         errorMsg = "User name and password does not match"; 
         break; 
        default: 
         errorMsg = error.toString(); 
       } 
       onLoginFailed(errorMsg); 
      } 
     }; 

Es sagt Cannot resolve symbol SyncCredentials

io.realm.Realm Klasse arbeitet.

Meine Projektebene gradle Datei

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 
     classpath "io.realm:realm-gradle-plugin:3.7.2" 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1' 

     classpath 'me.tatarka:gradle-retrolambda:3.7.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.google.com' } 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

Gradle (Modul: app)

apply plugin: 'com.android.application' 
apply plugin: 'realm-android' 
apply plugin: 'com.jakewharton.butterknife' 
apply plugin: 'me.tatarka.retrolambda' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.amit.database" 
     minSdkVersion 22 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
//  jackOptions { 
//   enabled true 
//  } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    configurations.all { 
     resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 

    compile 'com.jakewharton:butterknife:8.8.1' 
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 

    compile "android.arch.lifecycle:runtime:1.0.0-alpha9" 
    compile "android.arch.lifecycle:extensions:1.0.0-alpha9" 
    annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9" 

    compile group: 'com.google.guava', name: 'guava', version: '22.0-android' // or 22.0-android for the Android flavor 
    compile 'com.android.support:design:25.3.1' 
} 

Hauptziel ist Android App mit Reich-Objekt-Server auf aws-EC2 zu verbinden. Es funktioniert und kann vom Browser aus aufgerufen werden.

Antwort

2

hinzufügen

realm { 
    syncEnabled = true 
} 

in gradle (Modul: app) Bereich Sync-Funktion

So final Gradle zu verwenden (Modul: app)

apply plugin: 'com.android.application' 
apply plugin: 'realm-android' 
apply plugin: 'com.jakewharton.butterknife' 
apply plugin: 'me.tatarka.retrolambda' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.amit.database" 
     minSdkVersion 22 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
//  jackOptions { 
//   enabled true 
//  } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    configurations.all { 
     resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' 
    } 
} 
realm { 
    syncEnabled = true 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 

    compile 'com.jakewharton:butterknife:8.8.1' 
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 

    compile "android.arch.lifecycle:runtime:1.0.0-alpha9" 
    compile "android.arch.lifecycle:extensions:1.0.0-alpha9" 
    annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9" 

    compile group: 'com.google.guava', name: 'guava', version: '22.0-android' // or 22.0-android for the Android flavor 
    compile 'com.android.support:design:25.3.1' 
} 
+0

Hinweis: Dieser Kommentar ist diese Frage und Diese Antwort wurde von mir gepostet. – amit77309

Verwandte Themen