- Learning Android Google Maps
- Raj Amal W.
- 404字
- 2021-07-09 21:54:30
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.
- C語言程序設(shè)計案例教程(第2版)
- Leap Motion Development Essentials
- Java Web基礎(chǔ)與實例教程(第2版·微課版)
- VSTO開發(fā)入門教程
- SQL基礎(chǔ)教程(視頻教學(xué)版)
- HTML5+CSS3網(wǎng)頁設(shè)計
- 用戶體驗增長:數(shù)字化·智能化·綠色化
- Mastering Drupal 8 Views
- Oracle 18c 必須掌握的新特性:管理與實戰(zhàn)
- OpenMP核心技術(shù)指南
- Mastering Machine Learning with scikit-learn
- Django 2.0 入門與實踐
- jBPM6 Developer Guide
- 編譯原理學(xué)習(xí)與實踐指導(dǎo)
- Java Web程序開發(fā)參考手冊