Google Play 服务和 Firebase 冲突

Google Play Services and Firebase conflicts

我想同时使用 firebase 和 google 播放服务依赖项。但它会引起一些冲突。当我添加播放服务依赖项时,firebase 依赖项不起作用。你知道如何同时使用这两个依赖项吗?谢谢。

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.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
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'
implementation 'com.google.android.gms:play-services:11.8.0'

改变这个:

implementation 'com.google.android.gms:play-services:11.8.0'

进入这个:

implementation 'com.google.android.gms:play-services:12.0.1'

com.google.android.gms:* 和 com.google.firebase:* 15.0.0 之前的依赖项必须是同一版本。在 15.0.0 之后,不再是这种情况。有关详细信息,请参阅 https://developers.google.com/android/guides/versioning

需要注意的是,您也不应该再使用 com.google.android.gms:play-services catch-all 单体目标,因为它包括 all Google在您的项目中使用服务和 Firebase 库,不必要地使您的应用程序膨胀,因为您不太可能需要使用所有目标。这种用法已经被劝阻了一段时间,实际上在 v15.0.0 中被删除了 (https://developers.google.com/android/guides/releases#april_12_2018_-_version_1500)