24

Map Activity doesn't showing map, it's appear as just white screen with zoom control buttons. Manifest File like this :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.demomap"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
   <permission
        android:name="com.example.demomap.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.example.demomap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.demomap.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyCTQZOcXFS3RpNSVe79HHN1xojat-2MbT4" />
    </application>
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
</manifest>

My XmL File Like these:

<?xml version="1.0" encoding="utf-8"?>
<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

Log Cat Error:

05-15 17:15:16.255: E/Google Maps Android API(26201): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

Please Help me.

Manish Dubey
  • 4,206
  • 8
  • 36
  • 65
Suraj
  • 550
  • 1
  • 5
  • 17
  • have you referenced google play services library in your map project? – Raghunandan May 15 '13 at 12:13
  • @Suraj have you followed all necessary steps? – TheFlash May 15 '13 at 12:14
  • @Raghunandan:Yes I give the referance of Google Play servives Library in my project – Suraj May 15 '13 at 13:01
  • @Pratik:I follow the all necessary steps... – Suraj May 15 '13 at 13:01
  • If you have followed all the steps in the map api v2 doc it should work. – Raghunandan May 15 '13 at 13:04
  • @Raghunandan:I do that all step again then also it not working.it show white screen with the zoom controllers. it gives error me in log cat:05-16 12:26:00.351: E/Google Maps Android API(8366): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors). – Suraj May 16 '13 at 06:58
  • @Suraj http://raghunandankavi.blogspot.in/2013/04/google-map-api-v2-on-android.html. part 1 tutorial . http://raghunandankavi.blogspot.in/2013/04/google-map-api-v2.html. part 2 tutorial. – Raghunandan May 16 '13 at 07:01
  • http://stackoverflow.com/a/22653551/1318946 – Pratik Butani Mar 26 '14 at 07:08

19 Answers19

42

Maybe the key isn't correct. You can try the following thing:

  • Be sure you Enter your right Package name like this
  • Test on a real device which updated latest google play. Or use emulator with this guide
  • Active google map api v2 for android at google console site enter image description here

Community
  • 1
  • 1
Tai Dao
  • 3,407
  • 7
  • 31
  • 54
29

I got this problem using MapView

fragment_map.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.gms.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
    String message = getArguments().getString(EXTRA_MESSAGE);
    v = inflater.inflate(R.layout.map_f, container, false);
    vh = new ViewHolder();
    assetHandler = new AssetHandler(getActivity());
    vh.mapView=assetHandler.mapViewHandler.set(v,R.id.mapview);
    vh.mapView.onCreate(savedInstanceState);

    vh.mapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            googleMap.getUiSettings().setMyLocationButtonEnabled(true);
            googleMap.setMyLocationEnabled(true);
            // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
            try {
                MapsInitializer.initialize(getActivity());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    return v;
}


@Override
public void onResume() {
    super.onResume();
    vh.mapView.onResume();


}

@Override
public void onPause() {
    vh.mapView.onPause();
    super.onPause();
}

@Override
public void onDestroy() {
    vh.mapView.onDestroy();
    super.onDestroy();
}

@Override
public void onLowMemory() {
    super.onLowMemory();
    vh.mapView.onLowMemory();
}

I noticed if the LifeCycle methods are not implemented, you will not be able to see the map as well. hope this is hopeful for some.

Ng Zhong Qin
  • 1,211
  • 2
  • 15
  • 28
7

many times the problem comes from not adding the google services support in the permissions in the manifest :

check this permission is present in your manifest :

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Driss Bounouar
  • 3,182
  • 2
  • 32
  • 49
6

I changed package name and update the console. I had everything correct (correct SHA1 key, package name and API key in manifest) but still got the same error message.

I had to uninstall app and restart phone for the issue to go away. It seems something was being cached.

TrueCoke
  • 2,406
  • 1
  • 16
  • 9
3

As been mentioned here this problem usually derives from the fact that you are not referencing the google-play-service library correctly. Please take a look at the first 3 steps of the following guide I wrote no integrating Google Maps in your application and make sure you are doing all the steps correctly:

Google Maps API V2

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • 5
    In my case the problem was due to the fact that I did not add this permission: – BoD Jun 03 '13 at 11:53
  • Well I glad my answer was helpful to you, @BoD : ) – Emil Adz Jun 03 '13 at 12:36
  • my problem got solved after adding the users permission for READ_SERVICES like user BoD. I don't know why this is not mentioned in google documentation. Thank you @Emil Adz – Thupten Jun 06 '13 at 01:48
3

I had the same problem as you but I solved it when I noticed that i didn't mentioned at creating a new app the package name in the API key///// you have to check that in the API google console.

must be the same package name at the console and the one in your eclipse.

hope that helps you.

menzous
  • 33
  • 5
2

My suggestion is you can use MapFragment. As far as i know almost all devices are upgraded to 11 and above. MapFragment supports 11 and above. Log into google api console again and check whether your application key is present there or not. I know that you have done it already. But check it again. Because am having an issue where the api key is not getting saved. I have to create a new project everytime. Maybe you are facing the same issue too.

stickypens
  • 103
  • 4
  • 1
    no, he can't use MapFragment. his min SDK he target is 8 therefore SupportMapFragment must be used. – Emil Adz May 15 '13 at 15:19
  • @EmilAdz: Yeah you are right. But am just giving him a suggestion that this is also possible if he chooses to make the minSDK 11 or above. – stickypens May 15 '13 at 15:31
  • @stickypens:i will check in google api console my application key present there. – Suraj May 16 '13 at 07:09
  • if somebody still looking answer, check here - the same problem: http://stackoverflow.com/a/17947755/1891118 – Oleksii K. Jul 30 '13 at 13:04
  • According to [this](http://developer.android.com/about/dashboards/index.html), `26.3%` of users are still using `API Level 10`. – theblang Nov 14 '13 at 16:23
2

I just spent a couple of hours on this same error. I initially did not have the debug keystore API key set up properly and my android device cached the incorrect API key that was hard-coded into my manifest. Eventually I simply deleted the app from the device, cleaned the project, and this cleared whatever residual API key was stored locally on the device. I ran the app again and everything worked like a charm!

Good Luck.

i2097i
  • 764
  • 7
  • 15
1

There are two types signed and unsigned apk.If your apk is signed,then you want to use release key.if you use debug key and signed an apk, it will not work. so use release key when you export an apk and check in real device. In this documentation, https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key it has given. Displaying the release certificate fingerprint.

Shadow
  • 6,864
  • 6
  • 44
  • 93
1

If you are using an API key created for debug.keystore, your maps will only render if you run your application on debug mode. Make sure you are doing that.

Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63
1

This is keystore issue on 99%.

1) I use for release and debug the same file debug.keystore which I copy from C:/Users/EEfimenko/.android/debug.keystore to C:\Users\EEfimenko\Android\MyApp\app folder for access directly like to 'debug.keystore' without "C:/Users/..." link

2) Then I add point to it from build.gradle (Module: app) file in 'android {': signingConfigs { debug { storeFile file('debug.keystore') } release { storeFile file('debug.keystore') } }

3) Run "keytool -list -v -keystore debug.keystore" command from cmd from C:\Users\EEfimenko\Android\MyApp\app folder and mix resulted SHA1 fingerprint with name of applet: FR:TY:CG.....YF:ER;com.myapp.nameofit

4) then I go to https://code.google.com/apis/console/b/0/?noredirect to:

a) Services and enable "Google Maps Android API v2" to ON state

b) put FR:TY:CG.....YF:ER;com.myapp.nameofit in "API Access" like Create new Android Key

Now you can see your map with key again like at beginning without key!:)

Iefimenko Ievgen
  • 379
  • 1
  • 5
  • 12
0

Did you activate Google Map Service in API console?

Nuraiz
  • 1,060
  • 6
  • 17
  • 35
0

I had the same problem, so I went ahead and created a new key at the API console. Also, make sure you follow instructions for recording your release key on the API console: Displaying the release certificate fingerprint

It works for me now...

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
0

Here's what I did.. 1) Changed the workspace. 2) From Lance Nanek's website, http://permalink.gmane.org/gmane.comp.handhelds.android.devel/98066 , it appears that - with the new library feature, you don't specify the Android projects you depend on in the Java Build Path section of the Properties. You do it in the Android section of the Properties.

and so, goto Application Project's Properties in Java Build Path -> hit the Projects - select library and remove it. That solved my problem !!

Prachi
  • 3,584
  • 2
  • 24
  • 39
0

In addition to the items to check ,mentioned above - I had generated the SHA1 key outside of eclipse. I then moved my project into eclipse (I was trying android studio) and eclipse automatically generated a new SHA1 key, so I had to generate a new API_KEY based on that.

Nargis
  • 4,687
  • 1
  • 28
  • 45
bo7o
  • 1
0

I just spent many hours on this. Turns out there was a different debug.keystore on my disk (search around to make sure you are using the correct one). Also, if you get this error, leave the app running for a bit. I got the error yet again when I added the correct SHA1/app in the Google API access, and while I was reading some docs suddenly the map appeared. Probably took 1-2 minutes.

EPagePete
  • 31
  • 3
0

You need to signed your apk with same sh1 which register at google api console same app package name and on the map v2 service at google api console, make sure signed your apk with same sh1 distribution debug.keystore then test on real device it will work like charm.

0

I have the same issue, solved by adding this to Manifest File.

 <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="google_maps_key" />

  
        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />
Mohamed AbdelraZek
  • 2,503
  • 4
  • 25
  • 36
-1

I couldn't get it to work until I added the following inside the application tag of my manifest:

<application>
...
   <uses-library android:required="true" android:name="com.google.android.maps" />
...
</application>

Hope this helps!