6

Sau khi cập nhật Android Studio từ Canary 3 đến Canary 4, lỗi sau được ném vào thời gian xây dựng.Android phụ thuộc có phiên bản khác nhau cho biên dịch và thời gian chạy

Android dependency 'com.android.support:support-support-v4' has different version for the compile (25.2.0) and runtime (26.0.0-beta2) classpath. You should manually set the same version via DependencyResolution.

Tôi đã chạy tìm kiếm hoàn chỉnh trong toàn bộ dự án và phiên bản 25.1.0 không được sử dụng.

App-build.gradle

android { 
compileSdkVersion 26 
buildToolsVersion '26.0.0' 


defaultConfig { 
    applicationId "com.xxx.xxxx" 
    minSdkVersion 14 
    targetSdkVersion 
    versionCode 1 
    versionName "1.0" 
    multiDexEnabled true 

} 


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

    lintOptions { 
     abortOnError false 
    } 

}} 
dependencies { 
implementation fileTree(dir: 'libs', include: ['*.jar']) 
testImplementation 'junit:junit:4.12' 
implementation project(':core') 
implementation com.google.android.gms:play-services-gcm:9.0.0' 

implementation('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true 
} 
implementation 'com.android.support:multidex:1.0.1' 
implementation 'com.flurry.android:analytics:7.0.0' 
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' 
implementation 'com.jakewharton:butterknife:8.6.0' 
implementation 'com.android.support.constraint:constraint-layout:1.0.2' 
} 

Thư viện-build.gradle:

apply plugin: 'com.android.library' 
android { 
compileSdkVersion 26 
buildToolsVersion '26.0.0' 

defaultConfig { 
    minSdkVersion 14 
    targetSdkVersion 
    versionCode 1 
    versionName "1.0" 
} 

} 

dependencies { 
implementation fileTree(dir: 'libs', include: ['*.jar']) 
implementation files('libs/model.jar') 
testImplementation 'junit:junit:4.12' 
implementation 'com.android.support:percent:26.0.0-beta2' 
implementation 'com.android.support:appcompat-v7:26.0.0-beta2' 
implementation 'com.android.support:support-core-utils:26.0.0-beta2' 

implementation 'com.squareup.retrofit2:retrofit:2.0.2' 
implementation 'com.squareup.picasso:picasso:2.4.0' 
implementation 'com.squareup.retrofit2:converter-gson:2.0.2' 
implementation 'com.squareup.okhttp3:logging-interceptor:3.2.0' 
implementation 'uk.co.chrisjenx:calligraphy:2.2.0' 
implementation 'com.google.code.gson:gson:2.2.4' 
implementation 'com.android.support:design:26.0.0-beta2' 
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1' 

} 

Lưu ý: Dự án được xây dựng tốt trong Canary 3

Trả lời

3

Bạn nên có thể thấy chính xác sự phụ thuộc nào đang kéo theo phần lẻ với tư cách là phụ thuộc bắc cầu bằng cách chạy đúng gradle -q dependencies lệnh cho dự án của bạn như đã mô tả ở đây:

https://docs.gradle.org/current/userguide/userguide_single.html#sec:listing_dependencies

Khi bạn theo dõi những gì đang kéo nó vào, bạn có thể thêm một loại trừ đó phụ thuộc cụ thể trong tập tin gradle của bạn với một cái gì đó như:

implementation("XXXXX") { 
    exclude group: 'com.android.support', module: 'support-compat' 
} 
+0

Hi, tôi chạy lệnh phụ thuộc gradle và tôi gửi bài url ảnh chụp màn hình ở đây, imgur.com/dL35BaN. Tôi không bao giờ sử dụng Firebase trong dự án của mình. Thêm vào dòng đó trong gcm, nó không hoạt động mặc dù – DroidLearner

+0

@DroidLearner Tôi có thể thiếu một cái gì đó, nhưng tôi không thấy bất kỳ tham chiếu đến com.android.support:support-compat trong ảnh chụp màn hình bạn đã đăng. Ngoài ra còn có một cảnh báo trong ảnh chụp màn hình đó đề cập đến cấu hình 'biên dịch' mà tôi không thấy trong tệp gradle của bạn trong OP. nó có khả năng là nó đến từ: submodule lõi. Bạn có thể đăng thông tin về gradle liên quan từ đó không? – jdonmoyer

+0

Xin chào, hãy đăng cho bạn toàn bộ tệp gradle có cây phụ thuộc tại đây .. tệp gradle ứng dụng -> https://gist.github.com/anonymous/93affc0d75eb96b59f9fde51332b9716 tệp gradle lõi -> https://gist.github.com/ anonymous/5c85031f26ff766109061ab1f00b833d cây phụ thuộc -> https://gist.github.com/anonymous/71dd33b6fa4dc63dd357889e8aff01ee Hy vọng điều này sẽ hữu ích. – DroidLearner

5

Tôi đã có lỗi tương tự, những gì giải quyết được vấn đề của tôi là. Trong thư viện của tôi thay vì sử dụng biên dịch hoặc triển khai, tôi sử dụng "api". Vì vậy, cuối cùng phụ thuộc của tôi:

dependencies { 
api fileTree(dir: 'libs', include: ['*.jar']) 
api files('libs/model.jar') 
testApi 'junit:junit:4.12' 
api 'com.android.support:percent:26.0.0-beta2' 
api 'com.android.support:appcompat-v7:26.0.0-beta2' 
api 'com.android.support:support-core-utils:26.0.0-beta2' 

api 'com.squareup.retrofit2:retrofit:2.0.2' 
api 'com.squareup.picasso:picasso:2.4.0' 
api 'com.squareup.retrofit2:converter-gson:2.0.2' 
api 'com.squareup.okhttp3:logging-interceptor:3.2.0' 
api 'uk.co.chrisjenx:calligraphy:2.2.0' 
api 'com.google.code.gson:gson:2.2.4' 
api 'com.android.support:design:26.0.0-beta2' 
api 'com.github.PhilJay:MPAndroidChart:v3.0.1' 
} 

Bạn có thể tìm thêm thông tin về "api", "thực hiện" trong liên kết này https://stackoverflow.com/a/44493379/3479489

+0

Điều này đã giúp tôi rất nhiều, cảm ơn. – sector11

1

sử dụng mã này trong buildscript của bạn (build.gradle root)

subprojects { 
    project.configurations.all { 
    resolutionStrategy.eachDependency { details -> 
     if (details.requested.group == 'com.android.support' 
       && !details.requested.name.contains('multidex')) { 
      details.useVersion "version which should be used - in your case 26.0.0-beta2" 
     } 
    } 
    } 
} 

Best Regards, Eddi

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