Android studio 将依赖项添加到build.gradle Android Studio时出错

Android studio 将依赖项添加到build.gradle Android Studio时出错,android-studio,Android Studio,我最初的想法是: dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.google.firebase:fire

我最初的想法是:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply plugin: 'com.google.gms.google-services'
当我尝试为google play服务添加依赖项时,我添加了以下代码:

implementation 'com.google.android.gms:play-services:11.8.0'
我现在得到了这个错误:

错误:任务“:app:processDebugGoogleServices”的执行失败。 请通过更新google服务插件的版本(有关最新版本的信息,请访问)或将com.google.android.gms的版本更新为11.0.4来修复版本冲突


错误在于appcompat依赖项和firebase依赖项,即使它们在我添加google play services依赖项之前工作正常。

您应该更新firebase依赖项以匹配
play services
版本

将您的Firebase依赖项更改为:

com.google.firebase:firebase-database:11.8.0
以及您的支持依赖项:

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'

这解决了firebase的错误,但我在appcompat dependencyim上仍然存在错误,我现在正在获取此错误--错误:任务的执行失败:app:transformDexArchiveWithExternalLibsDexMergerForDebug'>java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex