2016-04-19 31 views
5

tôi nhận được lỗi này trong khi xây dựng:android không thể tìm thấy vương quốc gradle phụ thuộc

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 

Trong gradle cấp dự án của tôi, tôi đã thêm vào như:

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

Trong cấp module của tôi:

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

Cách khắc phục lỗi này?

mức án gradle:

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

mức Module:

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

thêm rằng mô-đun trong dự án của bạn –

+1

Áp dụng các plugin vương-android lên đỉnh của tập tin build.gradle mức ứng dụng. áp dụng plugin: 'vương quốc-android' – Dharmaraj

+0

@MDI đã thêm –

Trả lời

8

Từ 0,88 trở đi Realm là một plugin, không phải là một sự phụ thuộc biên dịch, vì vậy bạn cần phải áp dụng các plugin realm-android để thay thế. Nó cũng được mô tả ở đây: https://realm.io/docs/java/latest/#installation

Lên trên mức xây dựng tập tin

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

App mức xây dựng tập tin

apply plugin: 'realm-android' 

Trong trường hợp của bạn, bạn nên loại bỏ:

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

Phiên bản mới nhất hiện tại: 'classpath" io.realm: realm-gradle-plugin: 1.0.1 "' Keep xem phiên bản mới nhất: https://realm.io/docs/java/latest/ –

+1

Hmm được cập nhật từ 0.84.1 đến 1.0.1 plugin, nhưng giờ đây bạn không thể tìm thấy Realm. Tôi có classpath được định nghĩa trong build.gradle và áp dụng plugin trong module của mình. Mô-đun là thư viện, đó có phải là vấn đề không? – Orbit

3

Bước 1: Thêm đường dẫn lớp sau phụ thuộc mã hóa vào tệp build.gradle mức dự án.

buildscript { 
repositories { 
    jcenter() 
} 
dependencies { 
    //check & update 3.0.0 with latest version 
    classpath "io.realm:realm-gradle-plugin:3.0.0" 
} 
} 

Bước 2: Áp dụng plugin realm-android vào đầu tệp build.gradle cấp ứng dụng.

apply plugin: 'realm-android' 

Tìm phiên bản mới nhất từ ​​https://realm.io/docs/java/latest/

enter image description here

Các vấn đề liên quan