android无法找到realm gradle依赖

Non*_*hoi 5 android realm gradle

我在构建时遇到此错误:

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
Run Code Online (Sandbox Code Playgroud)

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

classpath "io.realm:realm-gradle-plugin:0.88.3"
Run Code Online (Sandbox Code Playgroud)

在我的模块级别:

compile 'io.realm:realm-android:0.88.3'
Run Code Online (Sandbox Code Playgroud)

如何解决这个错误?

项目级别:

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

模块级别:

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
}
Run Code Online (Sandbox Code Playgroud)

Chr*_*ior 8

从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"
    }
}
Run Code Online (Sandbox Code Playgroud)

应用级构建文件

apply plugin: 'realm-android'
Run Code Online (Sandbox Code Playgroud)

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

dependencies {
    compile 'io.realm:realm-android:0.88.3'
}
Run Code Online (Sandbox Code Playgroud)