2017-01-06 75 views
0

AndroidStudio 2.2.3無法解析我的RealmRecyclerViewAdapter參考。我直接從Realm網站上查看了RecyclerViewAdaper示例。有人能幫我弄清楚爲什麼它找不到RealmRecyclerViewAdapter?AndroidStudio未找到RealmRecyclerViewAdapter - android realm-plugin:2.2.2

這裏是我的import語句:

import io.realm.OrderedRealmCollection; 
import io.realm.RealmRecyclerViewAdapter; //this fails 

這裏是我的項目級gradle這個文件:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 
     classpath 'io.realm:realm-gradle-plugin:2.2.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 
allprojects { 
    repositories { 
     jcenter() 
    } 
} 

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

這裏是我的應用程序級的gradle這個文件:

應用插件:「融爲一體。 android.application' apply plugin:'realm-android'

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.creditcardcalcx" 
     minSdkVersion 23 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

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:25.1.0' 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 
    compile 'com.android.support:recyclerview-v7:25.1.0' 
    compile 'com.android.support:design:25.1.0' 
} 

回答

1

呀,你錯過了以下依賴

dependencies { 
    compile 'io.realm:android-adapters:1.4.0' 
} 
+0

真棒,那工作!我覺得有一個依賴我失蹤了,但我沒有看到任何在他們的介紹文檔中提到的東西。你知道這些額外的依賴關係在他們的文檔中的任何地方被調用嗎? – ambr8978

+0

https://realm.io/docs/java/latest/#adapters – EpicPandaForce

+0

(儘管顯然他們沒有[realm android用戶存儲](https://github.com/realm/realm-android-user-商店)提到任何地方,所以我猜文檔不完整) – EpicPandaForce