问题描述
我在做一些工作的同时学习 Android.我正在尝试将应用的版本更新到 Android 8.0,其中包括使用的 sdk、库和外部 API.
我
所以目前我正在使用版本 12.0.1 来提供播放服务和 firebase 服务.像这样使用它:
实现 'com.google.android.gms:play-services-maps:12.0.1'实施 'com.google.android.gms:play-services-analytics:12.0.1'实施 'com.google.android.gms:play-services-ads:12.0.1'实施 'com.google.android.gms:play-services-auth:12.0.1'实施 'com.google.android.gms:play-services-gcm:12.0.1'实施 'com.google.firebase:firebase-core:12.0.1'实施 'com.google.firebase:firebase-analytics:12.0.1'实施 'com.google.firebase:firebase-crash:12.0.1'实施 'com.google.firebase:firebase-messaging:12.0.1'实施 'com.android.support:support-v4:27.1.0'实施 'com.android.support:appcompat-v7:27.1.0'
但如果我尝试仅使用 play-services
15.0.1 进行分析,那么它会给我另一个警告,即使用不同版本的播放服务和 firebase 服务可能会导致运行时崩溃.
所以这让我处于一个奇怪的境地,我用谷歌搜索和搜索,但找不到任何适合我的东西......在这里处理这个问题的正确方法是什么?我应该满足于 12.0.1 吗?或更新曾经有效的方法?(以前版本是 9.4.0 或类似的版本;在我进行 Android 8.0 升级之前)
这些是我的顶级 gradle 依赖项
类路径 'com.android.tools.build:gradle:3.1.3'类路径 'com.google.gms:google-services:4.0.2'
您不能将小于或等于 12 的 firebase 和 google play 服务版本与大于或等于 15 的版本混合使用.
因此您需要更新所有这些库的版本号:
实施 'com.google.android.gms:play-services-maps:15.0.1'实施 'com.google.android.gms:play-services-analytics:15.0.1'实施 'com.google.android.gms:play-services-ads:15.0.1'实施 'com.google.android.gms:play-services-auth:15.0.1'实施 'com.google.android.gms:play-services-gcm:15.0.1'实施 'com.google.firebase:firebase-core:16.0.1'实施 'com.google.firebase:firebase-analytics:16.0.1'实施 'com.google.firebase:firebase-crash:16.0.1'实施 'com.google.firebase:firebase-messaging:17.1.0'
检查一下:
https://firebase.google.com/support/release-notes/android
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
<块引用>从版本 15 开始,每个匹配 com.google.android.gms:play-services-*
和 com.google.firebase:firebase-*
的 Maven 依赖项是不再需要具有相同的版本号才能在构建时和运行时正常工作.
还可以在顶级 gradle 文件中使用以下 google play services 插件:
类路径 'com.google.gms:google-services:4.0.1'
i'm learning Android while doing some work on it. I'm trying to update an app's version to Android 8.0, that includes sdk, libraries and external APIs used.
I looked it up and it seems like 15.0.1 is the suggested version. But when i use it, gradle fails for play-services-analytics
and firebase
services to sync saying it cannot resolve the library and nor can it find the Repository if i press Install Repository.
So currently i'm using version 12.0.1 for both play services and firebase services. Using it like:
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-analytics:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
But if i try to use only the play-services
15.0.1 except for analytics then it gives me another warning that using different versions of play services and firebase services can lead to runtime crashes.
So it puts me in a weird situation, i've googled and searched, but cant find anything that works for me... What would be the correct way to deal with this here? Should i settle for 12.0.1? or update what ever works? (Previously the version was 9.4.0 or something along that line; before i was doing the Android 8.0 upgrade)
EDIT: These are my top level gradle dependencies
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
You cannot mix versions of firebase and google play services that are less than or equal to 12 with versions that are greater than or equal to 15.
Therefore you need to update the version number of all these libraries:
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-analytics:16.0.1'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
Check this:
https://firebase.google.com/support/release-notes/android
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
Beginning with version 15, each Maven dependency matching
com.google.android.gms:play-services-*
andcom.google.firebase:firebase-*
is no longer required to have the same version number in order to work correctly at build time and at run time.
Also use the following google play services plugin in the top level gradle file:
classpath 'com.google.gms:google-services:4.0.1'
这篇关于安卓 |无法为 15.0.1 版添加所有 Google 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!