0

i am trying out an android map application, when i run it there are no errors or problems in the code, i use my samsung galaxy s3 to test it but it keeps on displaying >"Unfortunately, maps has stopped".

Here's my java file

package com.maps;

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

public class Main extends MapActivity {

MapView map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map = (MapView) findViewById(R.id.mvMain);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

Here is my xml code

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

<com.maps.MapView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="AIzaSyAfv657yXaBMlBLAe2pw0VyJiPLiczDG7E"
    android:id="@+id/mvMain"/>

</LinearLayout>

Here is my manifest

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

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


<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"/>
    <activity
        android:name="com.maps.Main"
        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>
Raghav Sood
  • 81,899
  • 22
  • 187
  • 195

3 Answers3

0

A crash when using maps is often due to a bad API key. Double check that the key you are using is valid

MrK
  • 652
  • 1
  • 5
  • 17
0

Try to use Google Maps v2 for Android. Here you have a good tutorial. Anyway, your problem seems to be with the API key.

Marta Rodriguez
  • 1,944
  • 2
  • 16
  • 30
0

If GOOGLE API is not valid it will not show map that's it . Why don't you attach your manifest.xml file so that we can rectify your error. Otherwise check manifest file whether it contains reference of GOOGLEapi or not.

M Karthik
  • 11
  • 1