Monday, September 9, 2013

Android error: "Failed to load map. Error contacting Google servers. This is probably an authentication issue"

I encountered the error message "Failed to load map. Error contacting Google servers. This is probably an authentication issue" when I found my published KoordKonverter Android App was not displaying any Google Maps tiles in the MapView. I thought I had tested the App properly prior to publishing and I remembered it was functioning but apparently not.

I spent many frustrating hours checking and rechecking the code and recreating the Google Maps for Android V2 license keys. I validated my steps with the Android Maps V2 Quick Start here https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw and everything checked out.

In the end, it turned out that my production license key was problematic. During testing and debugging, I simply replaced the good debug license key in the AndroidManifest.xml file with the bad production key without clearing the cache on the device. The cached debug license key was still being used while testing and that was why the Google Maps tiles were still being displayed in the MapView.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dom925.convertor.koordkonverter"
android:versionCode="4"
android:installLocation="auto"
android:versionName="1.2.1" >
 

<permission
android:name="com.dom925.convertor.koordkonverter.permission.MAPS_RECEIVE"
android:protectionLevel="signature"
></permission>
<uses-permission android:name="com.dom925.convertor.koordkonverter.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />    
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
 
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />

<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" >
<activity
android:name="com.dom925.convertor.koordkonverter.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|uiMode|screenSize|smallestScreenSize|screenLayout"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
 
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
 
<activity
android:name="com.dom925.convertor.koordkonverter.GoogleMapsFragmentActivity"
android:configChanges="keyboard|keyboardHidden|orientation|uiMode|screenSize|smallestScreenSize|screenLayout"
android:label="@string/app_name"
android:exported="false"
>

</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|uiMode|screenSize|smallestScreenSize|screenLayout" >

</activity>

<!-- Remember to uninstall and install the app after changing the Google Maps key below -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="BIzaSyC5-hI2kloom7O7XC1h2vtoyuk26IFb2A0"
/>        
</application>
 
</manifest>


To properly test the app with the production license key, the app must be uninstalled from the device first.

No comments:

Related Posts with Thumbnails