2013-06-28 47 views
0

我尝试了一个android地图应用程序,当我运行它时没有错误或代码中的问题,我用我的三星Galaxy S3测试它,但它一直显示>“不幸的是,地图已停止“。android应用程序崩溃没有错误

这是我的java文件

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; 
} 

}

这里是我的XML代码

<?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> 

这里是我的清单

<?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> 
+4

logcat说什么? –

+1

我同意Raghav Sood,LogCat中应该有一些东西。看看那里有什么错误,并粘贴在这里。 – g00dy

+0

http://stackoverflow.com/questions/10383353/android-unlikely-google-maps-stopped?rq=1 – Gina

回答

0

使用地图时发生崩溃通常是由于API密钥错误造成的。仔细检查您使用的密钥是否有效

0

尝试使用适用于Android的Google地图v2。 这里你有一个good tutorial。 无论如何,你的问题似乎与API密钥。

0

如果GOOGLE API无效,它将不会显示地图。 为什么不附上您的manifest.xml文件,以便我们可以纠正您的错误。 否则检查清单文件是否包含GOOGLEapi的引用。