Rahul Iyer
Rahul Iyer

Reputation: 21025

Which Android platforms / API are compatible with Google Play Services versions?

I am new to Android development (but not development in general). In iOS, the documentation clearly states which versions of the iOS SDK a particular API is available with.

In Android I am confused. I am using android-10 platform, and my minimumSDK and targetSDK are both 10. I am using Google Play Services 7.5.0.

I understand that the api's I use in android-10 will still work with later versions of android (4.4.4, 5.0 etc). But how do I know that Google Play Services 7.5.0 will work will all OS versions from Lollipop back upto 2.3.3 ? I don't have enough devices for testing.

In my build.grade file I have specified:

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

I don't fully understand what these lines mean (I followed them from some tutorials). How do I know which Android OS versions these will be compatible with ? Are these lines in Build.gradle ok ?

Upvotes: 3

Views: 4612

Answers (2)

Chebyr
Chebyr

Reputation: 2181

It is better to check the availability / version of Google Play services on the device at run time.

As per https://developers.google.com/android/guides/setup

"Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK before you access Google Play services features."

"You are strongly encouraged to use the GoogleApiClient class to access Google Play services features. This approach allows you to attach an OnConnectionFailedListener object to your client. To detect if the device has the appropriate version of the Google Play services APK, implement the onConnectionFailed() callback method. If the connection fails due to a missing or out-of-date version of the Google Play APK, the callback receives an error code such as SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED."

Upvotes: 0

Eoin
Eoin

Reputation: 4066

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

When you use a plus instead of specifying the version, gradle will automatically download and use the latest version of the library that it finds. This is not recommended because the potential changes between versions of libraries could break your code when gradle starts using a new version. Its better to specify it yourself. For example

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

This imports the entire playservices library so you don't actually need the second play-services-ads:7.5.0 line as its all-ready imported.

Also as the playservices library is so big its not a good idea to use the entire thing. Its better to use only the modules that you will need for your app. Each part can be specified with a compile '<module>'. It will save you space and build time.

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

Finally to know what level playservices is compatable with check out the developers guide

Overview of Google Play Services

It says this

The Google Play services APK is delivered through the Google Play Store, so updates to the services are not dependent on carrier or OEM system image updates. In general, devices running Android 2.3 (API level 9) or later and have the Google Play services app installed receive updates within a few days. This allows you to use the newest APIs in Google Play services and reach most of the devices in the Android ecosystem. Devices older than Android 2.3 or devices without the Google Play services app are not supported.

Upvotes: 6

Related Questions