哪些Android平台/ API与Google Play Services版本兼容



我是Android开发的新手(但不是一般的开发)。在iOS中,文档清楚地说明了特定API可用于哪个版本的iOS SDK。

在Android中我很困惑。我使用的是android-10平台,我的minimumSDK和targetSDK都是10。我使用的是Google Play Services 7.5.0.

我知道我在android-10中使用的api仍然可以与更高版本的android(4.4.4, 5.0等)一起工作。但是我怎么知道Google Play Services 7.5.0是否能正常工作?从棒棒糖到2.3.3的所有操作系统版本是否都能正常工作?我没有足够的设备进行测试。

在我的构建。我指定的等级文件:

dependencies{
....
compile 'com.google.android.gms:play-services:+'
compile 'com.google.android.gms:play-services-ads:7.5.0'
....
}

我不完全理解这些行是什么意思(我从一些教程中学习了它们)。我怎么知道这些软件兼容哪些Android操作系统版本?这些行是在Build。Gradle ok ?

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

当你使用加号而不是指定版本时,gradle会自动下载并使用它找到的库的最新版本。不建议这样做,因为当gradle开始使用新版本时,库版本之间的潜在变化可能会破坏您的代码。你最好自己详细说明。例如

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

这将导入整个playservices库,因此您实际上不需要第二个play-services-ads:7.5.0行,因为它已经完全导入了。

也因为playservices库是如此之大,它不是一个好主意,使用整个东西。最好只使用应用程序所需的模块。每个部分都可以用compile '<module>'指定。这将节省空间和构建时间。

Google+ com.google.android.gms:play-services-plus:7.5.0
Google Account Login    com.google.android.gms:play-services-identity:7.5.0
Google Actions, Base Client Library com.google.android.gms:play-services-base:7.5.0
Google App Indexing com.google.android.gms:play-services-appindexing:7.5.0
Google App Invites  com.google.android.gms:play-services-appinvite:7.5.0
Google Analytics    com.google.android.gms:play-services-analytics:7.5.0
Google Cast com.google.android.gms:play-services-cast:7.5.0
Google Cloud Messaging  com.google.android.gms:play-services-gcm:7.5.0
Google Drive    com.google.android.gms:play-services-drive:7.5.0
Google Fit  com.google.android.gms:play-services-fitness:7.5.0
Google Location, Activity Recognition, and Places   com.google.android.gms:play-services-location:7.5.0
Google Maps com.google.android.gms:play-services-maps:7.5.0
Google Mobile Ads   com.google.android.gms:play-services-ads:7.5.0
Google Nearby   com.google.android.gms:play-services-nearby:7.5.0
Google Panorama Viewer  com.google.android.gms:play-services-panorama:7.5.0
Google Play Game services   com.google.android.gms:play-services-games:7.5.0
SafetyNet   com.google.android.gms:play-services-safetynet:7.5.0
Google Wallet   com.google.android.gms:play-services-wallet:7.5.0
Android Wear    com.google.android.gms:play-services-wearable:7.5.0

最后要知道什么级别的playservices是兼容的,请查看开发者指南

Google Play服务概述

上面写着

Google Play服务APK是通过Google Play商店交付的,因此服务的更新不依赖于运营商或OEM系统映像更新。通常情况下,运行Android 2.3 (API level 9)或更高版本并安装了Google Play服务应用的设备会在几天内收到更新。这让你能够在Google Play服务中使用最新的api,并触及Android生态系统中的大多数设备。Android 2.3之前的设备或没有Google Play服务应用的设备不支持。

最好在运行时检查设备上的Google Play服务的可用性/版本。

根据https://developers.google.com/android/guides/setup

"因为很难预测每个设备的状态,所以在访问Google Play服务功能之前,您必须始终检查兼容的Google Play服务APK。"

"强烈建议您使用googleapicclient类来访问Google Play服务功能。这种方法允许您将OnConnectionFailedListener对象附加到客户端。要检测设备是否具有适当版本的Google Play服务APK,请实现onConnectionFailed()回调方法。如果由于Google Play APK的版本缺失或过时而导致连接失败,则回调会收到一个错误代码,如SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED或SERVICE_DISABLED。"

最新更新