Shekhar
Shekhar

Reputation: 832

Unable to display Google map in android's google map activity

I am creating a simple android application where I want to display google maps so I used the google map's activity but when I am running the application on my device, I am getting a blank screen with Google written at the bottom left . I have used correct API Key. This is the Logcat. I am also not able to find the the "Google Maps Android API v2" in the Google Developer Console . There is only Google Maps Android API which I have already enabled.

  Authentication failed on the server.
    09-18 16:38:47.158    2315-2451/? E/Google Maps Android API﹕ Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
    09-18 16:38:47.163    2315-2451/? E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
        Ensure that the "Google Maps Android API v2" is enabled.
        Ensure that the following Android Key exists:
        API Key: AIzaSyA2PEin-GiKaerDpnoStcvKGmCmHJ2cZuI
        Android Application (<cert_fingerprint>;<package_name>): 85:84:5C:61:4D:15:26:5C:52:78:1F:86:9D:46:5A:C6:45:29:D1:B8;com.example.mapDemo
    09-18 16:38:49.438    5639-5639/? E/SQLiteLog﹕ (10) POSIX Error : 11 SQLite Error : 3850
    09-18 16:39:00.123  30704-30704/? E/[AccuTab]﹕ {[87A192EF54E76DF503A22F31216BFA0960788D40C82B44EE1702A58D5517331C]}
    09-18 16:39:00.123  30704-30704/? E/[AccuTab]﹕ {[5CD3AD49228511B775B4B89D43787C6921CE939C82941DF49B0235A31366AD0C155EAD47CE71200FB8BACB33B4B42DF281207C3087E99E0EA192762118CD2EC2]}
    09-18 16:39:13.708    3350-5382/? E/Watchdog﹕ !@Sync 391 [09-18 16:39:13.708]
    09-18 16:39:29.883    5639-5639/? E/SQLiteLog﹕ (10) POSIX Error : 11 SQLite Error : 3850
    09-18 16:39:43.708    3350-5382/? E/Watchdog﹕ !@Sync 392 [09-18 16:39:43.710]
    09-18 16:40:00.168  30704-30704/? E/[AccuTab]﹕ {[87A192EF54E76DF503A22F31216BFA09C9D803FB806A4AFA63BAF57FE025AD59]}
    09-18 16:40:00.173  30704-30704/? E/[AccuTab]﹕ {[5CD3AD49228511B775B4B89D43787C6921CE939C82941DF49B0235A31366AD0C155EAD47CE71200FB8BACB33B4B42DF281207C3087E99E0EA192762118CD2EC2]}
    09-18 16:40:13.708    3350-5382/? E/Watchdog﹕ !@Sync 393 [09-18 16:40:13.712]
    09-18 16:40:43.713    3350-5382/? E/Watchdog﹕ !@Sync 394 [09-18 16:40:43.714]
    09-18 16:40:51.918    5639-5639/? E/SQLiteLog﹕ (10) POSIX Error : 11 SQLite Error : 3850
    09-18 16:40:56.393    3350-5676/? W/ActivityManager﹕ ProcessRecord{a6c6e91 30584:com.google.android.youtube/u0a150} is already killed
    09-18 16:40:56.398    2649-2649/? E/lowmemorykiller﹕ Error writing /proc/30584/oom_score_adj; errno=22
    09-18 16:40:56.398    3350-5676/? E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!

This is the Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mapDemo" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!--
 The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but are recommended.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".SearchActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SearchResultActivity"
            android:label="@string/title_activity_search_result" >
        </activity>

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps" >
        </activity>
    </application>

</manifest>

This is the what I am getting

I have also given the api key in the google maps key. enter image description here

enter image description here

Upvotes: 0

Views: 770

Answers (2)

Shekhar
Shekhar

Reputation: 832

After searching for many hours I got to know that I moved my .android folder from C: drive to D: drive and have set the ANDROID_SDK_HOME with the new path but I didn't delete the previous folder. I was using the previous path to get the Certificate fingerprints: Md5 ,SHA1 which were not correct. This was the only mitake that I made which is why the Sha1 was not matching.

Earlier I was using this

keytool -list -v -keystore "C:\.android\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

to get the Certificate fingerprints but now I am using the correct path

keytool -list -v -keystore "D:\.android\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Had to follow the same procedure again on console.developers.google.com to get the API key and now I am able to get the map on the screen.

Upvotes: 1

Mohit Suthar
Mohit Suthar

Reputation: 9395

You should enable "Google Maps Android API v2" api on google developer console and whatever your Android key (API Key: AIzaSyA2PEin-GiKaerDpnoStcvKGmCmHJ2cZuI) generated on google console, you should put this on manifest file.

Upvotes: 0

Related Questions