【问题标题】:How to fix dependency conflict?如何解决依赖冲突?
【发布时间】:2018-06-03 16:33:10
【问题描述】:

冲突在哪里,如何解决,以及在未来寻找冲突的根源?

compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    minSdkVersion 17
    targetSdkVersion 27
}


implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'


implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'

implementation 'com.google.maps.android:android-maps-utils:0.4.3'

implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-crash:16.0.0'


apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 你需要将你根 build.gradle 中的插件更新为classpath 'com.google.gms:google-services:3.3.0'
  • 谢谢,我修改了它,现在当我同步或清理项目时它显示一个新错误:任务':app:processDebugResources'的执行失败。 > 处理资源失败,详情见上面的 aapt 输出。

标签: android android-gradle-plugin


【解决方案1】:

您的一个依赖项是具有不同版本的com.google.android.gms

我从github page 检查了com.google.maps.android:android-maps-utils:0.4.3。我发现它使用的是非常旧的地图版本,见上页。

dependencies {
    compile 'com.google.android.gms:play-services-maps:11.0.4'
}

作为解决方案,您可以

  1. 将您的播放服务依赖版本降级为与 ma​​ps-utils 相同
  2. 或者您可以通过从 github 页面下载升级此依赖 gms 版本,并将其作为模块添加到您的项目中。

请记住,如果您在应用中使用最新版本的 gms 依赖项,请在项目级别 build.gradle 中使用最新的 google-services。喜欢

classpath 'com.google.gms:google-services:3.3.0'

编辑 使用此配置来降级您的 gms 和 firebase 版本。

def GMS_VERSION = "11.0.4"
def FCM_VERSION = "11.0.4"

dependencies {
// ...
    implementation "com.google.android.gms:play-services-analytics:$GMS_VERSION"
    implementation "com.google.android.gms:play-services-location:$GMS_VERSION"
    implementation "com.google.android.gms:play-services-maps:$GMS_VERSION"
    implementation "com.google.android.gms:play-services-places:$GMS_VERSION"

    implementation 'com.google.maps.android:android-maps-utils:0.4.3'

    implementation "com.google.firebase:firebase-messaging:$FCM_VERSION"
    implementation "com.google.firebase:firebase-crash:$FCM_VERSION"
}

【讨论】:

  • 当我升级它时显示:找不到 com.google.maps.android:android-maps-utils:11.0.4.
  • 知道我也更新了:classpath 'com.google.gms:google-services:3.3.0'
  • 等我告诉你你的应用程序gradle的完整配置。
  • 为什么我需要按照你在(2.)中的建议下载模块,为什么不直接在依赖项下升级号呢?
  • 因为如果你只是升级版本,可能是库类会出错,因为新版本会发生变化。因此,如果您将其下载为模块并更改版本,则可以解决被贬低的模块错误。
【解决方案2】:

您的一个依赖项是具有不同版本的com.google.android.gms

没错。在谷歌,他们似乎修复它(旧注释):

  configurations.all {
      resolutionStrategy.force "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
  }

所以找出常用/最新使用的版本,然后使用resolutionStrategy.force

【讨论】:

    猜你喜欢
    • 2019-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-02
    • 1970-01-01
    • 1970-01-01
    • 2016-07-18
    • 1970-01-01
    • 2022-07-14
    相关资源
    最近更新 更多