【问题标题】:AndroidStudio not finding RealmRecyclerViewAdapter - android realm-plugin:2.2.2AndroidStudio 没有找到 RealmRecyclerViewAdapter - android realm-plugin:2.2.2
【发布时间】:2017-01-07 01:40:06
【问题描述】:

AndroidStudio 2.2.3 无法解析我的 RealmRecyclerViewAdapter 参考。我直接从 Realm 站点遵循了 RecyclerViewAdaper 示例。有人可以帮我弄清楚为什么找不到 RealmRecyclerViewAdapter 吗?

这是我的导入语句:

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 文件:

应用插件:'com.android.application' 应用插件:'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'
}

【问题讨论】:

    标签: android realm


    【解决方案1】:

    是的,您缺少以下依赖项

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

    【讨论】:

    • 太棒了,成功了!我认为我缺少一个依赖项,但我没有在他们的介绍文档中看到任何内容。你知道这些额外的依赖项是否在他们的文档中的任何地方被调用?
    • (虽然显然他们没有在任何地方提到realm android user store,所以我猜文档不完整)
    猜你喜欢
    • 2021-05-30
    • 2023-03-27
    • 2017-04-11
    • 2019-12-27
    • 2015-02-09
    • 2021-08-01
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多