我在我的应用程序中按照步骤sut up a Google Map来创建调试密钥。 问题是,当我用eclipse在调试模式下第一次运行应用程序时,一切正常,但后来如果我重新启动应用程序(不是使用eclipse,而是从我家),地图不再工作,它不会甚至出现...它只显示一个灰色页面。Android Maps v2仅在首次启动时运行
MY清单
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:debuggable="true" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY_KEY" />
MY CODE
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
// Check if we were successful in obtaining the map.
if (googleMap != null) {
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), zoom), 3000, null);
googleMap.clear();
MarkerOptions marker = new MarkerOptions().title(values[0]).snippet(values[1]).position(new LatLng(latitude, longitude));
googleMap.setInfoWindowAdapter(new Adapter_Marker(context));
googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker arg0) {
EDU.infosDialog(context, fieldNames, infos);
}
});
googleMap.addMarker(marker).showInfoWindow();
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" >
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/bar_messina" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
WHY ????
你可以发布你的Logcat –
你正在重新启动相同的应用程序或导出apk文件吗?我的意思是,应用程序仍然处于调试模式?所以,如果你连接了你的设备,你能看到日志吗? – Aiapaec
我没有导出.apk文件... Eclipse将它保存在我的手机上,然后当我拔下USB连接器时,地图不再工作 –