6

更新Android Studio從Canary 3Canary 4,在構建時拋出以下錯誤。Android依賴項具有不同版本的編譯和運行時

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.

我跑了整個項目的完整搜索和版本25.1.0沒有使用的地方。

的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' 
} 

圖書館-的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' 

} 

注:項目於加納利3

回答

3

建設精細你應該能夠確切地看到哪個依賴在奇數版本中拉動作爲這裏說明運行爲您的項目的正確gradle -q dependencies命令傳遞依賴:

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

一旦追查什麼在拉它,你可以添加排除到特定依賴於你的gradle這個文件像這樣:

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

您好,我跑了gradle這個依賴命令,我在這裏張貼的截圖的網址,imgur.com/dL35BaN。我從不在我的項目中使用Firebase。在gcm中添加了這行,雖然 – DroidLearner

+0

@DroidLearner可能會丟失一些東西,但我沒有在您發佈的屏幕截圖中看到對com.android.support:support-compat的任何引用。此外,該屏幕截圖中還有一個警告,指出在OP中您的gradle文件中沒有看到「編譯」配置。它很可能是來自核心子模塊。你能從那裏發佈相關的gradle信息嗎? – jdonmoyer

+0

嗨,在這裏張貼你的依賴樹的整個gradle文件.. 應用程序gradle文件 - > https://gist.github.com/anonymous/93affc0d75eb96b59f9fde51332b9716 核心gradle文件 - > https://gist.github.com/匿名/ 5c85031f26ff766109061ab1f00b833d 依賴關係樹 - > https://gist.github.com/anonymous/71dd33b6fa4dc63dd357889e8aff01ee 希望這會有所幫助。 – DroidLearner

5

我有同樣的錯誤,什麼解決我的問題是。在我的而不是使用編譯或實現我使用「API」。那麼,到底我的依賴關係:

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' 
} 

您可以在此鏈接找到「API」,「執行」的詳細信息https://stackoverflow.com/a/44493379/3479489

+0

這幫了我很多,謝謝。 – sector11

1

使用此代碼在您的buildscript(的build.gradle根)

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" 
     } 
    } 
    } 
} 

最好的問候, EDDI

相關問題