android 找不到 Realm gradle 依赖

标签 android gradle realm

我在构建时遇到这个错误:

Failed to sync Gradle project 'myapp'
Error:Could not find io.realm:realm-android:0.88.3.
Required by:
    myapp:app:unspecified

Search in build.gradle files

在我的项目级 gradle 中,我添加为:

classpath "io.realm:realm-gradle-plugin:0.88.3"

在我的模块级别:

compile 'io.realm:realm-android:0.88.3'

如何修复这个错误?

项目级gradle:

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

模块级别:

apply plugin: 'com.android.application'
apply from: '../config/quality/quality.gradle'
apply plugin: 'realm-android'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "xxxxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            debuggable true
        }
        release {
            minifyEnabled true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}



dependencies {
    compile 'io.realm:realm-android:0.88.3'
    //more dependencies here
}

最佳答案

从 0.88 开始,Realm 是一个插件,不是编译依赖,所以你需要应用插件 realm-android 来代替。此处也对其进行了描述:https://realm.io/docs/java/latest/#installation

顶级构建文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:0.88.3"
    }
}

应用级构建文件

apply plugin: 'realm-android'

在您的情况下,您应该删除:

dependencies {
    compile 'io.realm:realm-android:0.88.3'
}

关于android 找不到 Realm gradle 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36711792/

相关文章:

java - Android - Realm 如何通过 boolean 值查询

realm - Realm 中 copyToRealm() 的用例示例

android - Visual Studio Team Services 中的签名和对齐 APK 步骤(原为 Visual Studio Online)

Android NDK 尝试使用 sdk/ndk-bundle/sources/cxx-STL/gnu-libstdc++ 进行构建/但 gnu-libstdc++ 不存在

android - 用户切换主屏幕时小部件更新

java - 如何以编程方式正确获取操作栏大小?

java - ClassNotFoundException:无法运行应用程序

android-studio - ApplicationVariant、BaseVariantOutput 已弃用

android - 构建 apk 时如何减小 xml Assets 的大小

Swift3.0 中的 Realm 意外状态代码 : -34018