問(wèn)題描述
我在做一些工作的同時(shí)學(xué)習(xí) Android.我正在嘗試將應(yīng)用的版本更新到 Android 8.0,其中包括使用的 sdk、庫(kù)和外部 API.
我
所以目前我正在使用版本 12.0.1 來(lái)提供播放服務(wù)和 firebase 服務(wù).像這樣使用它:
實(shí)現(xiàn) 'com.google.android.gms:play-services-maps:12.0.1'實(shí)施 'com.google.android.gms:play-services-analytics:12.0.1'實(shí)施 'com.google.android.gms:play-services-ads:12.0.1'實(shí)施 'com.google.android.gms:play-services-auth:12.0.1'實(shí)施 'com.google.android.gms:play-services-gcm:12.0.1'實(shí)施 'com.google.firebase:firebase-core:12.0.1'實(shí)施 'com.google.firebase:firebase-analytics:12.0.1'實(shí)施 'com.google.firebase:firebase-crash:12.0.1'實(shí)施 'com.google.firebase:firebase-messaging:12.0.1'實(shí)施 'com.android.support:support-v4:27.1.0'實(shí)施 'com.android.support:appcompat-v7:27.1.0'
但如果我嘗試僅使用 play-services
15.0.1 進(jìn)行分析,那么它會(huì)給我另一個(gè)警告,即使用不同版本的播放服務(wù)和 firebase 服務(wù)可能會(huì)導(dǎo)致運(yùn)行時(shí)崩潰.
所以這讓我處于一個(gè)奇怪的境地,我用谷歌搜索和搜索,但找不到任何適合我的東西......在這里處理這個(gè)問(wèn)題的正確方法是什么?我應(yīng)該滿足于 12.0.1 嗎?或更新曾經(jīng)有效的方法?(以前版本是 9.4.0 或類(lèi)似的版本;在我進(jìn)行 Android 8.0 升級(jí)之前)
這些是我的頂級(jí) gradle 依賴(lài)項(xiàng)
類(lèi)路徑 'com.android.tools.build:gradle:3.1.3'類(lèi)路徑 'com.google.gms:google-services:4.0.2'
您不能將小于或等于 12 的 firebase 和 google play 服務(wù)版本與大于或等于 15 的版本混合使用.
因此您需要更新所有這些庫(kù)的版本號(hào):
實(shí)施 'com.google.android.gms:play-services-maps:15.0.1'實(shí)施 'com.google.android.gms:play-services-analytics:15.0.1'實(shí)施 'com.google.android.gms:play-services-ads:15.0.1'實(shí)施 'com.google.android.gms:play-services-auth:15.0.1'實(shí)施 'com.google.android.gms:play-services-gcm:15.0.1'實(shí)施 'com.google.firebase:firebase-core:16.0.1'實(shí)施 'com.google.firebase:firebase-analytics:16.0.1'實(shí)施 'com.google.firebase:firebase-crash:16.0.1'實(shí)施 '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 開(kāi)始,每個(gè)匹配 com.google.android.gms:play-services-*
和 com.google.firebase:firebase-*
的 Maven 依賴(lài)項(xiàng)是不再需要具有相同的版本號(hào)才能在構(gòu)建時(shí)和運(yùn)行時(shí)正常工作.
還可以在頂級(jí) gradle 文件中使用以下 google play services 插件:
類(lèi)路徑 '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'
這篇關(guān)于安卓 |無(wú)法為 15.0.1 版添加所有 Google 庫(kù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!