How to implement Google map into Android app?
Setup Google map API key
- Go to the Google Cloud Platform Console
- Select project a project
- Menu > APIs & Services > Credentials
- Select “Create Credentials“ > “API key“
- Set API key as below
- “Application restrictions”: “Android apps“
- “Restrict usage to your Android apps”:
- Package name: “xxxxxxx“
- SHA-1 certificate finger print for release app
- SHA-1 certificate finger print for debug app
- Save
Enable Google Map service
- Select “Dashboard“ > “Enable APIs and Services”
- Select “Maps SDK for Android”
- Enable “Maps SDK for Android“
Add API key into Android app
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="4.10" package="xxxxxxxxxx" android:versionCode="10"> ... <application android:label="@string/app_name"> <!-- Put your Google Maps V2 API Key here. --> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="YOUR_API_KEY" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application> </manifest>
YOUR_API_KEY is to be replaced with the API key generated
Errors
Why is map not displayed?
This might be because of usage restriction in Android debug mode
Leave a Reply