4

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" />
Ken
  • 295
  • 1
  • 6
  • 18
  • You need to register your keystore in google api panel. You have registered a debug key so your tedt app works. Your release key needs to be registered too – jb15613 Apr 30 '15 at 00:23
  • see my answer here .. it may help http://stackoverflow.com/questions/29782251/google-maps-in-an-android-app/29782436#29782436 – Charaf Eddine Mechalikh Apr 30 '15 at 00:26
  • For me the problem was because Android studio autocreated wrong package name I put in developer console without noticing it. Is was com.myproject.name.activities, but it should be com.myproject.name. For anyone experiencing gray screen make sure to put correct package name you can find in Android manifest – Vlado Pandžić Jan 24 '16 at 20:15

4 Answers4

3

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).

AC-OpenSource
  • 346
  • 1
  • 12
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" />
Community
  • 1
  • 1
Xcihnegn
  • 11,579
  • 10
  • 33
  • 33
  • yes i have this – Ken Apr 30 '15 at 10:21
  • Ok you could go to [Google Maps Android API v2](https://developers.google.com/maps/documentation/android/start#get_an_android_api_key) to check if something you were missing – Xcihnegn Apr 30 '15 at 10:39
2

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.

AmDroid
  • 131
  • 5
  • 4
    For future visitors: This permission is now completely unnecessary. The latest update of Google Play Services 3.1.59 made it useless. As a result, it can be removed. source http://stackoverflow.com/questions/14832911/android-map-v2-why-maps-receive-permission – Ken Apr 30 '15 at 10:23
2

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

oxsha
  • 233
  • 3
  • 9