2015-02-10 27 views
5

Tôi có một dự án thư viện bao gồm android đang hoạt động bằng Gradle. Để có được nó để làm việc tôi có thêmKhông thể phân giải phụ thuộc Android đang hoạt động trong Gradle khi Android hoạt động được bao gồm trong thư viện

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' 

và thêm kho cho nó như vậy:

repositories { 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
} 

Tuy nhiên nếu tôi làm điều này trong dự án thư viện, tôi nhận được lỗi:

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration ':app:_debugCompile'. 
    > Could not find com.michaelpardo:activeandroid:3.1.0-SNAPSHOT. 
    Searched in the following locations: 
     https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml 
     https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom 
     https://jcenter.bintray.com/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar 
     file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml 
     file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom 
     file:/Users/user/AndroidSDK/extras/android/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar 
     file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/maven-metadata.xml 
     file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.pom 
     file:/Users/user/AndroidSDK/extras/google/m2repository/com/michaelpardo/activeandroid/3.1.0-SNAPSHOT/activeandroid-3.1.0-SNAPSHOT.jar 
    Required by: 
     Condeco:app:unspecified > Condeco:common:unspecified 

tôi thêm mô-đun thư viện của tôi như vậy:

dependencies { 
    compile project(':common') 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:21.0.3' 
} 

Để loại bỏ lỗi này tôi có thêm kho để các module ứng dụng chính cũng trong cùng một cách:

repositories { 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
} 

Khi tôi làm điều này dự án biên dịch tốt.

Tôi có thể nhận dự án của mình để biên dịch với các kho được xác định chỉ trong dự án thư viện mà không phải thêm kho lưu trữ vào mô-đun ứng dụng chính không? Tôi chỉ muốn có mô-đun thư viện chăm sóc chính nó.

+0

bạn đã thử thêm 'mavenCentral() '? –

+0

Vâng tôi có. Tôi vẫn phải thêm điều đó vào cả mô đun dự án chính và dự án thư viện. Tôi chỉ muốn thêm nó vào thư viện. – MungoRae

+0

@MungoRae bạn đã bao giờ tìm ra giải pháp cho điều này? Tôi muốn làm điều tương tự. – Alan

Trả lời

0

Tôi cũng phải đối mặt với lỗi này và giải pháp sẽ như thế này.

Bạn cần phải chỉnh sửa build.gradle của android app module.

apply plugin: 'com.android.application' 

// Add this block 
buildscript { 
    repositories { 

    } 
    dependencies { 
    } 
} 

repositories { 
    mavenCentral() 
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
} 
// End of this block 
android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    ..... //Replace dots with your code 
} 

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' 
    }) 
    .... //Replace dots with your code 
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' //Add this line 
} 

Hope this helps.

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