Android: Map tiles not loading – and possible fixes

I have encountered two reasons for the Google Maps tiles not loading. One is rather common, and the other one only seem to affect some phones:

  • Missing/wrong Google Maps API key
  • Permissions placed after application tag in the AndroidManifest.xml

Missing/wrong Google Maps API key

Usage of the Google Maps API key is properly documented many places, like in tutorials, the official Android developer site and the Google API project pages.

Wrong placement of permissions in the AndroidManifest.xml

The part about wrong placement of the permissions in the manifest file bit me when trying to get my map based app working on the Sony Ericsson Xperia X10 mini pro. The app was working like a charm in every configuration I tried, except on this little beauty. The configurations I tried included:

  • HTC Desire running 2.1
  • T-Mobile G1 running 1.6
  • Various emulators running 1.5, 1.6, 2.1 and 2.2 with various screen sizes. Also one that matched the x10 mini pro screen size.
  • Of course the X10 mini pro running 1.6

I had defined my permissions below the application definition, and after a while I moved the tags above the tag, and this fixed it.

So this is not OK on the X10 mini pro (AndroidManifest.xml):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test.myapp" android:versionCode="1" android:versionName="1.0">
    <application android:label="@string/app_name" android:icon="@drawable/launcher_icon">
    	<uses-library android:name="com.google.android.maps" />
        <activity android:label="@string/app_name"
                  android:alwaysRetainTaskState="true" android:name=".views.Map">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

   <uses-permission android:name="android.permission.INTERNET"></uses>      
</manifest> 

While this works:

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

    <uses-permission android:name="android.permission.INTERNET"></uses>

    <application android:label="@string/app_name" android:icon="@drawable/launcher_icon">
    	<uses-library android:name="com.google.android.maps" />
        <activity android:label="@string/app_name"
                  android:alwaysRetainTaskState="true" android:name=".views.Map">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest> 

If someone can tell me why defining permissions below the application tag works on most set-ups, but not on the X10 mini, please enlighten me.

Leave a Reply

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