2012-04-30 63 views
1

main.xml中&的manifest.xml安卓:不幸的是谷歌地图停止

<?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<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:clickable="true" 
    android:state_enabled="true" 
    android:apiKey="0hiUaVXTa9WGmYKpnOEIfy2HddhBcpBTrIc1Qnw" /> 
</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.Map.test" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <application android:label="@string/app_name"> 
     <uses-library android:name="com.google.android.maps" /> 
     <activity android:name=".GoogleMaps" 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> 
<uses-permission android:name="android.permission.INTERNET"/> 
</manifest> 

GoogleMaps.java

import com.Map.test.R; 
import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapView; 
import android.os.Bundle; 
public class GoogleMaps extends MapActivity { 
private MapView mapView; 
@Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    mapView = (MapView) findViewById(R.id.map_view);  
    mapView.setBuiltInZoomControls(true); 
    } 
    @Override 
    protected boolean isRouteDisplayed() { 
    return false; 
    } 
} 

Eclipse是没有出现在我的代码的任何错误,也模拟器中运行但最后我得到“不幸的谷歌地图停止”的错误。 我可以知道这段代码有什么问题吗?

+0

欢迎来到SO。请发布Logcat输出。 –

回答

0

您是否尝试过不同的API密钥?前一段时间我遇到了同样的问题,我使用的是调试密钥,我不得不生成一个新密钥并使用它。我会先试着看看会发生什么。

+0

如何生成新密钥? 我已在此链接中生成旧密钥[link] https://developers.google.com/android/maps-api-signup – Sathishkumar

+0

您必须先为您的应用程序创建新的密钥库。现在你可能正在使用调试密钥库。您可以使用Eclipse为您的应用程序生成一个密钥存储库,无论如何您都需要这样做。 –

+0

THANKs ..现在工作。 – Sathishkumar