0

Realm objectServerExample에서 코드를 가져 왔습니다.Android 영역에서 SyncCredentials, SyncUser, ObjectServerError 기호를 확인할 수 없습니다. 하지만 RealmObject .. 클래스가 잘 작동합니다.

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); 
      } 
     }; 

그것은 Cannot resolve symbol SyncCredentials

io.realm.Realm 클래스가 작동 말한다.

내 프로젝트 수준 Gradle을 파일

// 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을 (모듈 : 응용 프로그램)

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' 
} 

주요 목표는 AWS-EC2에서 영역 오브젝트 서버와 안드로이드 응용 프로그램을 연결하는 것입니다. 작동 중이며 브라우저에서 액세스 할 수 있습니다.

답변

2

Gradle을에서

realm { 
    syncEnabled = true 
} 

추가 영역 동기화 기능을 사용하는 (모듈 응용 프로그램)을

그래서 최종 Gradle을 (모듈 : 응용 프로그램)

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

참고 :이 주석이 질문 이 대답은 모두 나에게 게시됩니다. – amit77309