Kalai Selvan.G
Kalai Selvan.G

Reputation: 482

Mapview failed to work on android device

I am trying to find the path between two cities using Mapview.

The Issue is Mapview failed to work,Getting grey grids and blocks instead of map in device only but works fine in simulator.

Here is my Manifest

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

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

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

    <activity
        android:label="@string/app_name"
        android:name=".MapDirectionActivity" >
        <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-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

</manifest> 

Here is my Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="xxxxxxxxxxxxxxxxxxxxxx"
/>

 </LinearLayout>

Upvotes: 0

Views: 162

Answers (2)

RobG
RobG

Reputation: 31

OK... The API Key for "debug" ONLY works on emulators. If you use Eclise to load the software in "debug mode" to a handset, you will get tiles, not a map. If you update the mapview with a "release" API key, then use Eclipse "EXPORT" to create an apk file, copy this to the sd card on the handset, then use an installer app (download free from Google Play) to install it on the phone IT WORKS!!!

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006944

Getting grey grids and blocks instead of map in device only but works fine in simulator.

Either:

  1. You do not have the right apiKey in your layout, corresponding with the signing key you used to sign your app, or

  2. Your device does not have Internet access or otherwise cannot reach Google's map tile servers

(a third possibility would be a missing INTERNET permission, but it looks like you have that)

Upvotes: 1

Related Questions