
Configuring Google Play services
Google Play services include the classes required for our map application. So, it is required to set it up properly. It differs for Eclipse with the ADT plugin and Gradle-based Android Studio. Let's take a look at both separately. It will be simple.
Android Studio
Configuring Google Play services with Android Studio is very simple. You need to add a line of code to your build.gradle
file, which contains the Gradle build
script required to build our project. There are two build.gradle
files. You must add the code to the inner app
folder's build.gradle
file. The following screenshot shows the structure of the project:

The code should be added to the second Gradle build file that contains our app module's configuration. Add the following code to the dependencies in the Gradle build file:
compile 'com.google.android.gms:play-services:7.5.0
The structure will be similar to the following code:
dependencies { compile 'com.google.android.gms:play-services:7.5.0' compile 'com.android.support:appcompat-v7:21.0.3' }
The 7.5.0
in the code is the version number of Google Play services. Change the version number according to your current version. The current version can be found from the values.xml
file present in the res/values
directory of the Google Play services library project.
The newest version of Google Play services can be referred to from https://developers.google.com/android/guides/setup.
That's it. Now resync your project. You can sync it like this: Tools | Android | Sync Project with Gradle files.
Now, Google Play services will be integrated with your project.
Eclipse
Let's take a look at how to configure Google Play services in Eclipse with the ADT plugin. First, we need to import Google Play services into the workspace. Then, select File | Import.
The following window will appear:

In this window, select Android | Existing Android Code Into Workspace.
Then, select Next. In the next window, browse the sdk/extras/google/google_play_services/libproject/google-play-services_lib
directory. It is given in the following image:

Finally, select Finish. Now google-play-services_lib
will be added to your workspace. Now, let's take a look at how to configure Google Play services with our application project. First, select your project. Then, right click on | Properties.
In the Library section, select the following: Add | google-play-services_lib.
Next, select OK; google-play-services_lib
will be added as a library to our application project. The following screenshot shows this:

In the next section, we will take a look at how to configure an API key and add permissions that will help us to deploy our application.