Android Tutorials
Google Maps
Steps to create a Google map application :
Create an android application and remember the
package name of the project.
Obtain API key from Google APIs Console.
Download and configure the Google Play
services SDK.
Add the required settings in your application's
manifest.
Add a map to your application.
Publish and run your application.
Step # 1:
Create an android application
Step # 2:
Obtain API key
Steps to obtain API key :
Add Java JDK path to your system.
List the SHA-1 fingerprint using cmd and this
command :
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias
androiddebugkey -storepass android -keypass android
Copy the SHA-1 fingerprint and go to your
account on Google APIs Console.
Click Create Project.
Turn on Google Maps Android API v2.
Steps to obtain API key : ( continued )
Create new Android Key using SHA-1
fingerprint and the package name of your
application separated by a semicolon.
Example :
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample
Keep the Android key and go to your application.
Step # 3:
Download and configure the
Google Play services SDK
Steps to download and configure the
Google Play services SDK :
Download and install the Google Play services
SDK using SDK Manger.
Import the Google-play-service-lib project to
your eclipse.
Add the Google-play-service-lib project as a
library to your project.
Step # 4:
Add the required settings in your
application's manifest
Steps to add the required settings in
your application's manifest :
Add the following element as a child of the
<application> element, by inserting it just before
the closing tag </application>.
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
Remember to replace the API_KEY with your
API key that you have got from Google APIs
Console.
Steps to add the required settings in
your application's manifest : (continued)
Add the following element as a child of the
<application> element, by inserting it just before
the closing tag </application>.
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Really I dont why I put this , but it solved my
problem with Google maps.
Steps to add the required settings in
your application's manifest : (continued)
Add the following permissions.
<uses-permission
<uses-permission android:name="android.permission.INTERNET"/>
android:name="android.permission.INTERNET"/>
<uses-permission
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-<!-- The
The following
following two
two permissions
permissions are
are not
not required
required to
to use
use
Google
Google Maps
Maps Android
Android API
API v2,
v2, but
but are
are recommended.
recommended. -->
-->
<uses-permission
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
android:name="android.permission.ACCESS_FINE_LOCATION"/>
Add the following <uses-feature> element.
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
Step # 5:
Add a map to your application
Steps to add a map to your application :
Add the following to the activity_main layout
XML or you can use drag and drop.
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Step # 6:
Publish and run your application
Steps to publish and run your application :
Use your phone to test this application because the
normal emulator doesnt support Google play
services.
If you want your emulator to run this application
you should add the Google play services to your
emulator.
To do that, follow the steps in the video.
Wait for Errors