Google Map Example in Android Studio
Google Map Example in Android Studio
Android
Appium
Python
PostgreSQL
Java Core
Java EE
JDBC
Maven
Spring Core
Angular JS
jQuery
Node JS
Log4j
Selenium
TestNG
Interview Questions
All Tutorials
Contact Me
Search
https://www.dev2qa.com/google-map-example-in-android-studio/ 1/13
11/3/2019 Google Map Example In Android Studio
Google map is the best digital map in the world. So embed google map in
android application is very user friendly and can improve user experience.
Google provide android APIs for android developer to integrate google map
service in their android application. This article will tell you how to do it step
by step.
1. First of all, you need to create a new google APIs project. Click google
developer console to open it and login, then click CREATE PROJECT to
create one project.
3. When the project creation process complete successfully, you can see
the new project in google APIs project list page. Click the project name
and then click Google APIs menu —> APIs & Services —> Dashboard
https://www.dev2qa.com/google-map-example-in-android-studio/ 2/13
11/3/2019 Google Map Example In Android Studio
5. In the new page click Enable button, after a while you can go to below
page, it prompt you to create a credential first.
https://www.dev2qa.com/google-map-example-in-android-studio/ 3/13
11/3/2019 Google Map Example In Android Studio
6. In the create credentials page, select Google Maps Android API in the
drop down list then click What credentials do i need? button.
7. Then google will give you a credential by your selected API service,
because google map credential is a API key, so it give you an API key in
the next credential detail page.
8. After create the project credential, you had better configure it to restrict
it’s usage for security reason. You can follow google prompts. We just
https://www.dev2qa.com/google-map-example-in-android-studio/ 4/13
11/3/2019 Google Map Example In Android Studio
9. To restrict the google maps API key used only by android apps, follow
below steps.
First get the android apps package name from your
AndroidManifest.xml file.
Then get the debug SHA-1 certificate fingerprint from app / res /
values / google_maps_api.xml file. The file will be generated
automatically after you add google maps activity in you android app.
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIEN
You can also add your credentials to an existing key, using these values:
Package name:
B1:BE:24:B9:08:60:AF:89:9B:B5:FE:64:7F:68:FD:46:32:39:21:7F
SHA-1 certificate fingerprint:
B1:BE:24:B9:08:60:AF:89:9B:B5:FE:64:7F:68:FD:46:32:39:21:7F
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyAUh
</resources>
10. Click Add package name and fingerprint button to add above value in
it, click Save button to save the result.
https://www.dev2qa.com/google-map-example-in-android-studio/ 5/13
11/3/2019 Google Map Example In Android Studio
2. Input new android project name and input project save location folder,
click next.
https://www.dev2qa.com/google-map-example-in-android-studio/ 6/13
11/3/2019 Google Map Example In Android Studio
3. In next dialog select minimum SDK version click next. In the Add an
Activity To Mobile dialog, choose Google Maps Activity, click next and
input related data and click Finish button.
https://www.dev2qa.com/google-map-example-in-android-studio/ 7/13
11/3/2019 Google Map Example In Android Studio
6. Find Google Maps API related play services description in this url
: https://developers.google.com/android/guides/setup
7. Open project build.gradle file, add above google maps API dependency
library in it. You can find the dependency has been added by android
studio automatically.
https://www.dev2qa.com/google-map-example-in-android-studio/ 8/13
11/3/2019 Google Map Example In Android Studio
com.google.android.gms:play-services-maps:12.0.0
LEAVE A REPLY
Your email address will not be published. Required fields are marked *
https://www.dev2qa.com/google-map-example-in-android-studio/ 9/13