Just add Google Play Services to you project. To make the Google Play Services API's available to your app, add a new build rule under dependencies
for the latest version of play-services
.
Open the build.gradle file inside your application module directory.
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
}
Be sure you update this version number each time Google Play services is updated.
As described in the Google Play services overview, Google Play delivers service updates for users on Android 2.3 and higher through the Google Play Store app. However, updates might not reach all users immediately, so your app should verify the version available before attempting to perform API transactions.
Because each app uses Google Play services differently, it's up to you decide the appropriate place in your app to verify the Google Play services version. For example, if Google Play services is required for your app at all times, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can check the version only once the user navigates to that portion of your app.
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,