2014-11-04 19 views
17

Tôi đang cố nhập cả thư viện hỗ trợ Android. Tôi đang cố gắng đưa GoogleMaps AP2 vào Ứng dụng Android của mình. Vì vậy tôi cần cả hai thư viện. Tôi đang sử dụng AndroidStudio và Gradle.Thêm thư viện hỗ trợ v7, v13 với gradle không hoạt động

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    apt "org.androidannotations:androidannotations:$AAVersion" 
    compile "org.androidannotations:androidannotations-api:$AAVersion" 
    compile 'com.android.support:appcompat-v7:21.0.+' 
    // compile 'com.google.android.gms:play-services:6.1.+' 
    compile "com.android.support:support-v13:18.0.+" 
    compile "com.loopj.android:android-async-http:1.4.5" 
    repositories { 
     mavenCentral() 
    } 
    compile "com.github.chrisbanes.actionbarpulltorefresh:library:+" 
    compile 'joda-time:joda-time:2.5' 
} 

Lỗi này là:

Module version com.android.support:support-v13:18.0.0 depends on libraries but is not a library itself 

Trả lời

29

Bạn phải sử dụng phiên bản mới nhất hỗ trợ-v13:. 21,0 +

Bạn có lỗi này vì cả hai appcompat và hỗ trợ-v13 phụ thuộc vào support-v4 và họ là một phiên bản xung đột.

Không phải là lỗi tốt nhất bằng cách này.

+0

Được rồi, tôi nhận được đó. Và làm thế nào Tôi có thể sửa vấn đề này không? Không có cách nào để biên dịch cả hai? –

+5

Chỉ cần thay thế phiên bản hỗ trợ-v13 để biên dịch "com.android.support:support-v13:21.0. +" ' – pdegand59

3

Cuối cùng mã này đang làm việc cho tôi trong:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    apt "org.androidannotations:androidannotations:$AAVersion" 
    compile "org.androidannotations:androidannotations-api:$AAVersion" 
    compile 'com.android.support:support-v4:20.0.+' 
    compile "com.android.support:appcompat-v7:20.0.+" 
    compile "com.android.support:support-v13:20.0.+" 
    compile 'com.google.android.gms:play-services:6.1.+' 
    compile "com.loopj.android:android-async-http:1.4.5" 
    repositories { 
     mavenCentral() 
    } 
    compile "com.github.chrisbanes.actionbarpulltorefresh:library:+" 
    compile 'joda-time:joda-time:2.5' 
} 
+0

Bây giờ, hãy sử dụng' biên dịch " com.android.support:support-v13:23.0. + "' –

1

Tôi chạy vào một vấn đề tương tự và thấy https://code.google.com/p/android/issues/detail?id=73802: 'Sự hỗ trợ-v13: 19.1.0 thư viện có siêu dữ liệu không chính xác, có lẽ phát sinh từ việc chuyển đổi để AAR từ JAR '

tôi đã cố gắng xây dựng với một loạt các kết hợp khác nhau và tìm thấy những điều sau đây:

1) Nếu sử dụng hỗ trợ-v13 < hỗ trợ-v13: 20 .0.0, tất cả thư viện hỗ trợ khác cũng phải ở trước 20.0.0

2) Nếu sử dụng support-v13> = support-v13: 20.0.0, các thư viện hỗ trợ khác có thể là bất kỳ phiên bản nào.

Ví dụ:

hỗ trợ-v13 < hỗ trợ-v13: 20.0.0 với libs hỗ trợ khác> = 20.0.0

compile "com.android.support:support-v4:22.0.0" 
compile "com.android.support:appcompat-v7:22.0.0" 
compile "com.android.support:support-v13:19.0.0" 

Lỗi: Module phiên bản com.android.support: support-v13: 19.0.0 tùy thuộc vào thư viện nhưng không phải là thư viện chính nó

support-v13 < support-v13: 20.0.0 w thứ i libs hỗ trợ khác < 20.0.0

compile "com.android.support:support-v4:19.0.0" 
compile "com.android.support:appcompat-v7:19.0.0" 
compile "com.android.support:support-v13:19.0.0" 

xây dựng tốt

hỗ trợ-v13> = hỗ trợ-v13: 20.0.0

compile "com.android.support:support-v4:13.0.0" 
compile "com.android.support:appcompat-v7:22.0.0" 
compile "com.android.support:support-v13:20.0.0" 

xây dựng tốt

Vì vậy, chỉ cần đảm bảo hỗ trợ-v13 ít nhất là hỗ trợ-v13: 20.0.0 trở lên.

0

Remove dòng: compile 'com.android.support:appcompat-v7:21.0.+'

0

Đối với v13 thêm compileSdkVersion 21, targetSdkVersion 21, và biên dịch "com.android.support:support-v13:21.0.+" Bạn không thể bình luận dòng 'com.android.support:appcompat-v7:21.0.3', điều này sẽ làm việc mẫu gradle My

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 21 
buildToolsVersion "21.1.2" 

defaultConfig { 
    applicationId "someId" 
    minSdkVersion 11 
    targetSdkVersion 21 
    versionCode 5 
    versionName "1.1" 
} 
buildTypes { 
    release { 
     minifyEnabled true 
     shrinkResources true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.google.android.gms:play-services:6.5.87' 
compile "com.android.support:support-v13:21.0.+" 

}

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