Firebase引用版本冲突解决:Android dependency 'com.google.android.gms:play-services-basement' has different

博客详细介绍了在Android项目中遇到Firebase插件版本冲突的问题,特别是'com.google.android.gms:play-services-basement'。作者通过更新Firebase依赖、查看依赖树结构并排除冲突模块的方式成功解决冲突。此外,还提到了其他解决版本冲突的方法,如force设置版本、exclude排除模块和处理不同配置下的冲突。
摘要由CSDN通过智能技术生成
  • 前两天在RN项目中集成原生的firebase,之后报错插件版本冲突,报错信息如下:

What went wrong:
Execution failed for task ‘:app:preDebugBuild’.
Android dependency ‘com.google.android.gms:play-services-basement’ has different version for the compile (16.0.1) and runtime (16.1.0) classpath. You should manually set the same version via DependencyResolution
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
###尝试

  • 这个问题可是折磨了我大半天,按照网上搜索的解决方式各种尝试

1. 方法一:

  • 在项目的build.gradle中加入
allprojects {
	subprojects {
			project.configurations.all {
				resolutionStrategy.eachDependency { details ->
					if (details.requested.group == 'com.android.support'
							&& !details.requested.name.contains('multidex') ) {
						details.useVersion "16.1.0"
					}
				}
			}
		}
}

2. 方法二:

classpath 'com.google.gms:google-services:4.0.2' // Just updated the version here.

3. 方法三:

  • 各个module的dependencies里的compile改为implementation
    然而,并没有什么卵用

解决方法

  • 之后静下心来好好思考了下,依赖版本冲突,肯定是存在重复依赖的问题。从这个思路着手:

第一步:

第二步:

在这里插入图片描述

关于Google Play services的各个分支介绍(MX5一定要安装XXXXXX-448分支) 要想使用google playgoogle map等google应用,就必须安装Google Play Service,但Google Play Service有太多分支了,最近终于搞明白各个分支代表什么。 版本号最后三位(2104405-XYZ)分别表示Android版本,cpu的arm系列,屏幕密度(DPI)。 下面是具体分支介绍: Notes / What's New Uploader's notes: To figure out the right version of Google Play services for your Android device, go to Settings -> Apps -> Google Play services, and look at the last 3 numbers in the parentheses. You'll see something like -XYZ where: 1.第一位X * X defines Android version: 0 for Android =5.0 // 4和7表示Android5.0及以上 8 for Android TV // 8表示Android电视应用 2.第二位Y * Y defines CPU architecture: 1 for armeabi 3 for armeabi-v7a // 32位版本 4 for arm64-v8a // 64位v8版本,MX5必须是这个 7 for x86 // x86主要是对intel cpu来说的 3.第三位Z * Z defines DPI: 0 for universal 2 for 160 4 for 240 6 for 320 8 for 480 // MX5选这个就行了 Notes: It seems that -7YZ builds became -4YZ with Google Play services 6.5. If you were on -7YZ before, you should now install -4YZ. Looks like -8YZ builds are for Android TV. Examples: -014 for Android <5.0 armeabi CPU 240 DPI device -438 for Android 5.0+ armeabi-v7a CPU 480 DPI device -876 for Android TV x86 CPU 320 DPI device 国内用户可以直接从以下镜像网站下载最新到Google Play Service http://www.apkmirror.com/apk/google-inc/google-play-services/ 目前最新版本Google Play services 7.8.93 MX5用户可以安装以下分支: Google Play services 7.8.93 (2104405-448) http://www.apkmirror.com/apk/google-inc/google-play-services/google-play-services-7-8-93-2104405-448-android-apk-download/ 另外,安装后好需要禁止系统自带【应用中心】自动安装更新,可以设置面流量更新,但不要设置“静默安装更新包”,否则新版本发布后会自动更新成应用中心的最新版本,而最新版本的后三位可能不是你想要的分支,这时候就会导致弹出提示架构不符等。
`com.google.gms.google-services` 是 Google Play 服务的 Gradle 插件,它通常用于处理 Google 服务配置文件(如 `google-services.json`),这些文件包含了与 Google 服务相关的配置信息,比如 FirebaseGoogle 登录。要在你的 Android 工程中写入这个插件,通常需要在项目的根目录下的 `build.gradle` 文件(不是应用模块下的)中添加 Google 服务的类路径依赖,并在应用模块的 `build.gradle` 文件中应用这个插件。 以下是添加 `com.google.gms.google-services` 插件的基本步骤: 1. 打开你的项目根目录下的 `build.gradle` 文件。 2. 在 `buildscript` 部分的 `dependencies` 块中添加 Google 服务插件的类路径依赖: ```gradle buildscript { repositories { google() // Google 的 Maven 仓库 jcenter() // 可选,如果你的项目依赖于此 } dependencies { classpath 'com.google.gms:google-services:4.x.x' // 使用最新的版本号 } } ``` 3. 确保你的项目同步(Synchronize Project with Gradle Files)。 4. 打开应用模块的 `build.gradle` 文件(通常是 `app/build.gradle`)。 5. 在文件底部或合适的位置,添加 `apply plugin: 'com.google.gms.google-services'` 以应用插件。 ```gradle apply plugin: 'com.android.application' android { // Android 配置部分 } dependencies { // 依赖配置部分 } apply plugin: 'com.google.gms.google-services' // 在这里应用插件 ``` 确保你已经正确安装了 Google 服务插件,并且同步了你的项目。在同步之后,Android Studio 会自动处理 `google-services.json` 文件,并且根据该文件内容进行配置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值