android – In Version 2 Map view does not show map-ThrowExceptions

Exception or error:

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.

How to solve:

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

###

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.

###

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"/>

###

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.

###

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

###

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.

###

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.

###

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.

###

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.

###

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.

###

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!:)

###

Did you activate Google Map Service in API console?

###

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…

###

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 !!

###

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.

###

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.

###

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.

###

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!

Leave a Reply

Your email address will not be published. Required fields are marked *