【问题标题】:Android Maps v2 works only the first time is launchedAndroid Maps v2 仅在第一次启动时工作
【发布时间】:2014-01-13 21:14:10
【问题描述】:

我在我的应用程序中按照sut up a Google Map 的所有步骤来创建调试密钥。 问题是,当我第一次使用 eclipse 在调试模式下运行应用程序时,一切正常,但后来如果我重新启动应用程序(不使用 eclipse,而是从我家),地图不再工作,甚至没有出现...它只显示一个灰色的页面。

我的清单

<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" />

我的代码

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>

为什么????

【问题讨论】:

  • 你能发布你的 Logcat
  • 您要重新启动同一个应用程序还是导出 apk 文件?我的意思是,该应用程序仍处于调试模式?那么,如果你连接了你的设备,你能看到日志吗?
  • 我还没有导出 .apk 文件... Eclipse 将它保存在我的手机上,然后当我拔下 USB 连接器时,地图不再起作用

标签: java android eclipse google-maps android-maps-v2


【解决方案1】:

SHA-1 密钥与软件本身相关联(在本例中为 Eclipse)。如果项目在不同的 PC 软件上运行。我怀疑 SHA-1 密钥是不同的。更改 SHA-1 密钥,请参阅您的软件,看看是否有帮助。

【讨论】:

  • 我没有在不同的电脑软件中运行它 我只是在没有使用 eclipse 的情况下运行它...只需从手机的应用程序菜单中选择它
  • 尝试清除应用程序的缓存和数据,这样会在您的手机上重新启动应用程序。看看进展如何。
  • 我不知道为什么,但它创建了 2 个具有相同名称和相同包的应用程序...我删除了所有应用程序,它运行良好
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-15
  • 2016-02-17
  • 2017-09-19
相关资源
最近更新 更多