Google Maps on Android shows grey screen

11,540

Solution 1

please add permission:

<permission
    android:name="com.pkg.map.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" >
</permission>

Here com.pkg.map is the package name where map activity exists.

Solution 2

You have to check if the user has Google Play Services installed.

private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;

private boolean checkPlayServices() {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                    PLAY_SERVICES_RESOLUTION_REQUEST).show();
        }
        return false;
    }
    return true;
}

Android will automatically handle the resolution of the issue (if resolve-able).

Solution 3

Do you have following:

Add the Google Play services version to your app's manifest

Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

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

Solution 4

You might be using the wrong API key. Check that you're using an API key for Android and not Javascript. Basically, if you need the key, google "get API key android". Here: https://developers.google.com/maps/documentation/android-api/signup

Share:
11,540
Ken
Author by

Ken

Updated on June 24, 2022

Comments

  • Ken
    Ken about 2 years

    I had this issue before, where Google Maps shows grey screen and no maps displayed.

    I fixed this issue by installing google services on the test environment and it works fine.

    The problem now is that the published app is showing the same grey screen (No maps) for people who installed the app from Google Play.

    I cant ask people to go and download Google Services so they get my app working.

    Is there anyway I can embed these services into my app or any other way to fix this issue.

    Thanks

    I have this in google_maps_api.xml

     <string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
         AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
     </string>
    

    I also have this in the manifest

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