The first thing we need to do is to add the Google Play Services library to our project. This should already have been done by the wizard when we created the project, but I recommend you to double-check it now.
The library needs to be added to the build.gradle
file of the main module. Note that Android Studio projects contain a top-level build.gradle
and a module-level build.gradle
for each module. We will modify the one that is under the mobile
module.
Make sure that the play services' library is listed under dependencies:
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
}
At the point of writing, the latest version is 7.3.0. The basic features have not changed much and they are unlikely to change. You could force Gradle to use a specific version of the library, but in general I recommend you use the latest version.
Once you have it, save the changes and click...