In Version 2 Map view does not show map
Asked Answered
C

19

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.

Clypeus answered 15/5, 2013 at 12:5 Comment(8)
have you referenced google play services library in your map project?Introjection
@Clypeus have you followed all necessary steps?Bondman
@Raghunandan:Yes I give the referance of Google Play servives Library in my projectClypeus
@Pratik:I follow the all necessary steps...Clypeus
If you have followed all the steps in the map api v2 doc it should work.Introjection
@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).Clypeus
@Clypeus raghunandankavi.blogspot.in/2013/04/…. part 1 tutorial . raghunandankavi.blogspot.in/2013/04/google-map-api-v2.html. part 2 tutorial.Introjection
https://mcmap.net/q/470254/-failed-to-load-map-error-contacting-google-servers-issue-with-android-google-maps-api-v2-duplicateBelligerent
F
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

Filose answered 23/5, 2013 at 10:59 Comment(8)
Its really amazing that.. one has to go and activate maps api even he has already got its api key..thanks buddyFerricyanide
man what a nightmare. Spent 2 hours checking everything but didn't know you had to explicitly turn on Google Maps Android API v2. It should be implicitly available.Zurkow
@jigar do you test on Emulator?Filose
@jigar So install like my post to use google map api v2 on emulatorFilose
Wuau! Spent 15 minutes trying to find out where that last option was!! haha. For those who are searching where to go to switch on "Google Maps Android Api v2" and "Google Maps API v2" its within the website where you manage the API Access.Inappetence
This single answer has finally ended my two day struggle. +1 to you sir.Frodi
Why is "Google Maps API v2" needed. My understanding is that one only needs to turn on "Google Maps Android API v2"...Zoes
There is no such thing as Google Maps API v2 now.Sesquialtera
F
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.

Forefinger answered 17/1, 2015 at 17:28 Comment(3)
Yup...that helped me :DBasilicata
Didn't expect that! Implementing all lifecycle methods for the MapView worked! Thanks!Talya
Had no clue for few hours, It never clicked that I had to implement onResume method once....Chadbourne
B
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"/>
Backsaw answered 6/6, 2013 at 9:19 Comment(1)
It was this for me, good catch, thanks. Should really read to the end of the install doc.Laterality
P
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.

Postage answered 3/8, 2013 at 8:39 Comment(1)
Yes, I had to uninstall my app and restart my phone in order for this to work.Zoes
J
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

Jaquelynjaquenetta answered 15/5, 2013 at 12:43 Comment(3)
In my case the problem was due to the fact that I did not add this permission: <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>Favouritism
Well I glad my answer was helpful to you, @Favouritism : )Jaquelynjaquenetta
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 AdzWornout
E
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.

Enthrone answered 17/5, 2013 at 0:18 Comment(1)
for google maps example package name is ;com.example.mapdemoSparrowgrass
W
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.

Wendell answered 15/5, 2013 at 14:41 Comment(5)
no, he can't use MapFragment. his min SDK he target is 8 therefore SupportMapFragment must be used.Jaquelynjaquenetta
@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.Wendell
@stickypens:i will check in google api console my application key present there.Clypeus
if somebody still looking answer, check here - the same problem: https://mcmap.net/q/458692/-failed-to-load-map-error-contacting-google-servers-this-is-probably-an-authentication-issueProsperous
According to this, 26.3% of users are still using API Level 10.Eldin
B
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.

Bleed answered 25/7, 2013 at 22:13 Comment(0)
H
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.

Housewife answered 15/5, 2013 at 12:20 Comment(0)
M
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.

Meaghanmeagher answered 10/1, 2014 at 4:4 Comment(0)
G
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!:)

Galvan answered 30/4, 2015 at 15:16 Comment(0)
L
0

Did you activate Google Map Service in API console?

Legatee answered 23/5, 2013 at 10:54 Comment(0)
Z
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...

Zoes answered 4/6, 2013 at 2:27 Comment(0)
N
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 !!

Newcomen answered 8/6, 2013 at 4:59 Comment(0)
C
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.

Casa answered 9/7, 2013 at 5:36 Comment(0)
S
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.

Swarm answered 2/8, 2013 at 18:9 Comment(0)
G
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.

Gummy answered 18/6, 2014 at 5:50 Comment(0)
T
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" />
Topographer answered 31/7, 2021 at 12:37 Comment(0)
S
-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!

Scaramouch answered 25/7, 2013 at 22:4 Comment(2)
this is for api v1 !! deprecated !!Ossy
@user901987 Your advise is only relevant to Maps V1, not V2.Zoes

© 2022 - 2024 — McMap. All rights reserved.