Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleMap V2 loads map randomly android

I have implemented Google Map V2 in my application, Everything works just fine. Checked on 2-3 mobiles and tabs it runs perfectly,

But it runs for 10 to 15 times a day on single device.,after that it does not load map on same device and gives following error.

05-06 07:17:41.866: E/Google Maps Android API(17217): Failed to load map. Could not contact Google servers.

In short, sometimes it displays map and sometimes it does not.

I m using map key generated from android debug key.

Please suggest some solutions for this.

My Manifest

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ocatalog.mapdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.ocatalog.mapdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.ocatalog.mapdemo.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyA9E-oCIM2d5rlhxnsJf66Bly57JXpkiKI" />

        <activity
            android:name="com.ocatalog.mapdemo.MapDemoActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
like image 206
Niket K Avatar asked Nov 12 '22 06:11

Niket K


1 Answers

I am experiencing the same problem, the maps are running OK on multiple devices, but randomly show a blank screen, sometimes for days.

When I debug the code I can see that all actions like adding markers, overlays, etc. are executed properly. Also, no idea if this is related, but the Geocoder seems to be working correctly in the meanwhile, so it is definitely not related to an Google Services connectivity issue(or is it?).

Besides, the map also works fine offline and the cache data is stored properly (well, most of the time that is).

Clearing my app's cache and data also doesn't help. Nor does doing so for the Google Services app. However, reinstalling the application seems to fix it for most of the time, but does not prevent it from reoccurring.

like image 174
Vladislav Avatar answered Nov 15 '22 00:11

Vladislav