0

I am trying to learn Android development & doing it the first time to do some hands-on to develop my ideas. I want to load the google map with the current location on the emulator.

Referred SE Questions: Failed to load map. Error contacting Google servers. This is probably an authentication issue

Initially, I faced the problem "won't run unless I update google play service in android studio"

The problem got resolved after changing:

compile 'com.google.android.gms:play-services:9.0+

I also corrected API_KEY by generating the API_KEY from the link given in code file. Now I am not getting that error but still not able to load the map on the emulator. These seem to be connection issue & I added the permission in manifest files as well. But the problem still persists. Kindly guide me & provide your valuable suggestions.

google_maps_api.xml

<resources>
    <!--
    TODO: Before you run your application, you need a Google Maps API key.

    To get one, follow this link, follow the directions and press "Create" at the end:

    https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96%3Bcom.example.kapilj3.meetmeapp

    You can also add your credentials to an existing key, using this line:
    6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96;com.example.kapilj3.meetmeapp

    Alternatively, follow the directions here:
    https://developers.google.com/maps/documentation/android/start#get-key

    Once you have your key (it starts with "AIza"), replace the "google_maps_key"
    string in this file.
    -->
    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIza_MY_ACTUAL_KEY</string>
</resources>

AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>
kapilddit
  • 1,729
  • 4
  • 26
  • 51
  • 1
    Is your MapActivity opening, and show you a white(not loaded) map ? – Ionut J. Bejan Jul 27 '17 at 06:12
  • Yes correct. It is white screen with google at bottom – kapilddit Jul 27 '17 at 06:17
  • 1
    I had the same issue, and everything was set correctly..Later I found out that the problem was the API_KEY I used...on google console, click your api and use (Android api_key) the one autogenerated by them :) Let me know if it worked – Ionut J. Bejan Jul 27 '17 at 06:22

1 Answers1

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

add this code to your application manifiest

Azim Shaikh
  • 589
  • 6
  • 18