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

相关问题