Bowen
Bowen

Reputation: 67

Google Maps not displaying tiles in android app

I know this type of question has been asked many times but I am really am confused without to where my error/mistake lies. My map shows up on my emulator and Samsung Galaxy 3 when I run the app, but all it displays are grey tiles which can be zoomed in or out.

Here is my manifest file

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

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

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permisison 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"/>

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

<permission 
    android:name="com.android.maptesting.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.android.maptesting.permission.MAPS_RECEIVE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <uses-library android:name="com.google.android.maps" />

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="A#####################################4" />

    <activity
        android:name="com.android.maptesting.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>

</application>

</manifest>

Here is my layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map_view"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:layout_below="@+id/tridView"
    android:layout_centerHorizontal="true"
    android:clickable="true" 
    android:enabled="true" 
    android:apiKey="A####################################4" />

</RelativeLayout>

And finally my java file

package com.android.maptesting;

import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MainActivity extends MapActivity {

    private MapView mapView;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mapView = (MapView) findViewById(R.id.map_view);       
        mapView.setBuiltInZoomControls(true);
    }

    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

}

Then all the logcat says when the app is "Run" on Galaxy S3 is:

Couldn't get connection factory client
IOException processing: 26
java.io.IOException: Server returned: 3
at     android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileReuqest.readResponseData(BaseTileRequest.java.115)
at     android_maps_conflictavoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)

and will keep repeating that regularly. So implies that my app is trying to get the tiles but is not succeeding.

From looking at forums and other stackoverflow questions the common problems arise in the permissions in the manifest file. I honestly believe I have everything in there. The next common issue was the API key. I did get a bit confused with this but followed the tutorials and other peoples steps thoroughly. Though when it came to finally giving the key, google asked for a SHA-1 and not an MD5 that other people were seeming to use. I did try the MD5 but google did not except this as a valid response to obtaining a key.

I am trying to use "Google Maps Android API v2", and when obtaining the key I used "Create new Android Key" and used my SHA-1 followed by ";" then my package name. To obtain the SHA-1 I followed this step by step instructions > https://stackoverflow.com/a/11493316/1833809 (Yes I know it says MD5 but I used the -v option to see all fingerprints).

To be honest I would love it if there is a stupid or simple mistake somewhere, as I have been struggling over this for a few days now and lost patience. So I apologise again for a probably repetition of this type of question, but the other solutions don't seem to help me.

Upvotes: 0

Views: 2973

Answers (2)

Mitch Bukaner
Mitch Bukaner

Reputation: 181

I´ve been having this issue with Eclipse in debugging mode.

Delete the file "debug.keystore", run you app. It will fail but it also will crreate a new debug.keystore. Get the hexadecimal printcode from that keystore and go to google to get your key for that code. to see your code write on a console:

keytool -list -alias androiddebugkey -keystore C:\Users\USUARIO.android\debug.keystore -storepass android -keypass android

Then write your key in your MapView and run. it should work.

Upvotes: 1

Emil Adz
Emil Adz

Reputation: 41099

Frankly saying it does looks like a key problem. First off all I would suggest you to go over those 2 post I wrote on getting the Google Map API V2 key and creating a Google Map:

Google Maps API V2

Getting Key for Google API

If those guides won't help you, from my experience you could try to delete you current: debug.keystore file from the C:\Users\"Your username"\.android directory.

and recreate it running a compilation of an android project.

Next try to follow the Key guide again as you will receive a new SHA1 key.

Upvotes: 2

Related Questions