如何消除“避免使用捆绑版本的Google Play服务SDK”警告?


69

我在Android应用中使用Google Play服务,因此我有依赖项build.gradle

compile 'com.google.android.gms:play-services:10.2.1'

但是Android Studio对此发出警告:Avoid using bundled version of Google Play services SDK

Android警告

此警告是什么意思?我应该如何避免呢?我已经在Google上搜索了很多,却没有找到很多相关信息。


2
这是因为播放服务有很多包含它里面的依赖..看看这里.. developers.google.com/android/guides/setup ..选择要转而使用它们的所有的依赖。
ZeroOne

@ZeroOne酷。谢谢你快速的回复。您能为这个问题添加答案,以便我接受吗?
Frederick Zhang

1
我没有意识到。当我阅读一些教程时,并没有意识到运行Gradle时有多糟糕。我很高兴在我的项目早期发现这一点。
Juan Mendez

对于我来说,我最终不需要任何GooglePlay服务;阅读ZeroOne的评论后,我删除了:在Gradle中实施“ com.google.android.gms:play-services:12.0.1”,然后APK的发布大小减少了3MB。。谢谢
Bruno L.

Answers:


149

在6.5之前的Google Play服务版本中,您必须将整个API包编译到您的应用中。在某些情况下,这样做会使将应用程序中的方法数量(包括框架API,库方法和您自己的代码)保持在65,536个限制以下变得更加困难。从6.5版开始,您可以选择将Google Play服务API选择性地编译到您的应用中

内部编译com.google.android.gms:play-services:12.0.0包含大量依赖项。请参见下文。使用播放服务可能会导致dex问题和繁重的应用程序。只选择您真正要依赖的对象:)

Google Play services API    Description in build.gradle

Google+                  com.google.android.gms:play-services-plus:12.0.0
Google Account Login     com.google.android.gms:play-services-auth:12.0.0
Google Actions, 
Base Client Library      com.google.android.gms:play-services-base:12.0.0
Google Address API       com.google.android.gms:play-services-identity:12.0.0
Google Analytics         com.google.android.gms:play-services-analytics:12.0.0
Google Awareness         com.google.android.gms:play-services-awareness:12.0.0
Google Cast              com.google.android.gms:play-services-cast:12.0.0
Google Cloud Messaging   com.google.android.gms:play-services-gcm:12.0.0
Google Drive             com.google.android.gms:play-services-drive:12.0.0
Google Fit               com.google.android.gms:play-services-fitness:12.0.0
Google Location and 
Activity Recognition     com.google.android.gms:play-services-location:12.0.0
Google Maps              com.google.android.gms:play-services-maps:12.0.0
Google Mobile Ads        com.google.android.gms:play-services-ads:12.0.0
Google Places            com.google.android.gms:play-services-places:12.0.0
Mobile Vision            com.google.android.gms:play-services-vision:12.0.0
Google Nearby            com.google.android.gms:play-services-nearby:12.0.0
Google Panorama Viewer   com.google.android.gms:play-services-panorama:12.0.0
Google Play Game         com.google.android.gms:play-services-games:12.0.0
SafetyNet                com.google.android.gms:play-services-safetynet:12.0.0
Android Pay              com.google.android.gms:play-services-wallet:12.0.0
Android Wear             com.google.android.gms:play-services-wearable:12.0.0

火力基地

Firebase API                Description in build.gradle

Analytics                com.google.firebase:firebase-core:12.0.0
Realtime Database        com.google.firebase:firebase-database:12.0.0    
Cloud Firestore          com.google.firebase:firebase-firestore:12.0.0   
Storage                  com.google.firebase:firebase-storage:12.0.0
Crash Reporting          com.google.firebase:firebase-crash:12.0.0  
Authentication           com.google.firebase:firebase-auth:12.0.0    
Cloud Messaging          com.google.firebase:firebase-messaging:12.0.0 
Remote Config            com.google.firebase:firebase-config:12.0.0  
Invites and 
Dynamic Links            com.google.firebase:firebase-invites:12.0.0 
AdMob                    com.google.firebase:firebase-ads:12.0.0 
App Indexing             com.google.firebase:firebase-appindexing:12.0.0 
Performance Monitoring   com.google.firebase:firebase-perf:12.0.0   

EDIT 以上版本已被弃用。他们使用单独的版本控制。请参阅

Google Play服务下方的链接 -https: //developers.google.com/android/guides/setup Firebase- https :
//firebase.google.com/docs/android/setup


Google Cloud Messaging已弃用。请改用Firebase Massaging。
拉米兹·安萨里

1
@ZeroOne ...如何获取所有依赖项的最新版本?
mdb

14

Google Play服务包含许多单独的API。您可以访问所需的任何内容,而不必访问包含所有内容的捆绑软件。这是更好的方法。见表1号这里

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.