2014-01-13 38 views
2

我在我的应用程序中按照步骤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 ????

+0

你可以发布你的Logcat –

+0

你正在重新启动相同的应用程序或导出apk文件吗?我的意思是,应用程序仍然处于调试模式?所以,如果你连接了你的设备,你能看到日志吗? – Aiapaec

+0

我没有导出.apk文件... Eclipse将它保存在我的手机上,然后当我拔下USB连接器时,地图不再工作 –

回答

1

SHA-1键绑定到软件本身(本例中为eclipse)。如果项目运行在不同的PC软件上。我会怀疑SHA-1密钥是不同的。改变SHA-1键参考你的软件,看看它是否有帮助。

+0

我没有在不同的PC软件中运行它我刚运行它无需使用eclipse ...只需从我的手机中的应用程序菜单中选择 –

+2

尝试清除应用程序的缓存和数据,以这种方式将启动手机上的应用程序新功能。看看它是如何发展的。 – JustWe

+0

我不知道为什么,但它创建了2个具有相同名称和相同包的应用程序...我删除了所有应用程序,并且它完美地工作 –

相关问题