所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)

时间:2019-04-07 07:23:02

标签: android firebase build.gradle

我在build.gradle中发现一个错误问题。向我发送消息“所有com.android.support库都必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。“实现”底部有一条红线com.android.support:appcompat-v7:28.0.0'”。我不知道我哪里出了错。

谢谢

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation 'com.android.support:palette-v7:28.0.0'
implementation "com.android.support:cardview-v7:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"

//Firebase Dependencies
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.0.1'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-appindexing:17.1.0'
implementation 'com.google.firebase:firebase-ads:17.2.0'

implementation 'com.google.android.gms:play-services-ads:17.2.0'

implementation 'com.artjimlop:altex-image-downloader:0.0.4'
implementation 'com.yalantis:ucrop:2.2.0'

implementation 'com.github.danimahardhika:cafebar:1.3.1'
implementation 'com.github.qiugang:EditTag:v1.2.4-beta2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.airbnb.android:lottie:2.6.0'
implementation 'com.github.chyrta:AndroidOnboarder:0.7'

//Error Fixer
implementation 'com.android.support:multidex:1.0.3'

implementation 'com.android.support:support-vector-drawable:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

3 个答案:

答案 0 :(得分:0)

enter image description here

您一定会看到像这样的红线吗?将鼠标悬停在红线上,您将看到这样的对话框。找到哪些库仍旧(在我的情况下是cardview),并在gradle中添加该库的最新版本,您的问题可能会得到解决。

如果仍然没有,那么我看到您正在使用旧的Firebase库,请将它们也更新为最新版本。

答案 1 :(得分:0)

错误消息非常清楚,“所有com.android.support库必须使用完全相同的版本规范”。例如,您有以下内容:

implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'

您正在尝试为同一库构建2个不同的版本16.0.1和16.0.7。这可能导致运行时崩溃。选择您要保留的版本,然后删除另一个。例如,如果要版本16.0.7,请将这两行替换为:

implementation 'com.google.firebase:firebase-core:16.0.7'

答案 2 :(得分:0)

您的gradle依赖项需要重做:

  1. 清除重复的依赖项,并且每行仅添加一次!

行:

  • implementation 'com.android.support:appcompat-v7:28.0.0'
  • implementation "com.android.support:design:28.0.0"

是两次。每个只能保留一次!

  1. 每个库仅使用一个版本定义。 Firebase核心具有两个不同版本的导入:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'

选择两行之一。

  1. 依赖关系的依赖项不应具有不同的版本。您有许多使用其他版本的com.android.support组件的库,这可能导致此错误。

例如:

  • 'com.artjimlop:altex-image-downloader:0.0.4'使用com.android.support:appcompat-v7:23.1.0参见here

  • 'com.yalantis:ucrop:2.2.0'使用com.android.support:appcompat-v7:24.2.0参见here

  • 'com.github.danimahardhika:cafebar:1.3.1'使用com.android.support:designcom.android.support:cardview-v7参见here

  • 'com.github.qiugang:EditTag:v1.2.4-beta2'使用com.android.support:recyclerview-v7com.android.support:appcompat-v7参见here

  • 等等,几乎所有第三方github库的清单都在继续。

您可以使用以下配置来排除所有依赖项。

configurations {
  all*.exclude module: "appcompat-v7"
  all*.exclude module: "recyclerview-v7"
  all*.exclude module: "design"
  all*.exclude module: "cardview-v7"
  // ... etc in case there are extra dependencies
}

甚至更好的是,您可以遍历每个依赖项并排除导致重复的确切库:

即。对于'com.artjimlop:altex-image-downloader:0.0.4',您应该使用以下方式更改implementation 'com.artjimlop:altex-image-downloader:0.0.4'

implementation ('com.artjimlop:altex-image-downloader:0.0.4') {
   exclude group: 'com.android.support', module: 'appcompat-v7'
   // for more than one just add it in a new line ie.
   // exclude group: '<first part till : symbol>', module: '<second part between : symbol and version>'
}

如果您想进一步了解依赖项问题的依赖项,请阅读本文here