Android BLANK PAGE上的谷歌地图(白色)

时间:2011-11-04 20:07:40

标签: android google-maps google-maps-api-3

我试图在我的应用程序上显示一个基本的谷歌地图但是它不工作它显示白色屏幕而不是我有一个网络连接我也检查我的MANEFIST一百次我生成一个deubg键并且我确定它是真

我想如果有人能引导我做错了什么?

我还没有修改代码但是在EMULATOR上的第二个地图显示并消失了,在我的设备上它并没有突然它在模拟器上不显示AT ALL。



public class MyMapDisplayActivity extends MapActivity {

MapController MControl;
GeoPoint GeoP;
MapView mapview;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

            //Map
            MapView mapview = (MapView) findViewById(R.id.mapview);
             mapview.displayZoomControls(true);
             mapview.setBuiltInZoomControls(true);

             double lat = 19.7888;
             double longi = 52.535;


             GeoP = new GeoPoint ((int) (lat *1E6),(int) (longi *1E6));


             MControl = mapview.getController();
             MControl.animateTo(GeoP);
             MControl.setZoom(14);




             MyLocationOverlay LocationOverlay = new MyLocationOverlay(this, mapview);
             mapview.getOverlays().add(LocationOverlay);
             LocationOverlay.enableCompass();
             LocationOverlay.enableMyLocation();
}//onCreate

//Map
@Override
protected boolean isRouteDisplayed() {
return false;
}

MapController MControl; GeoPoint GeoP; MapView mapview; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Map MapView mapview = (MapView) findViewById(R.id.mapview); mapview.displayZoomControls(true); mapview.setBuiltInZoomControls(true); double lat = 19.7888; double longi = 52.535; GeoP = new GeoPoint ((int) (lat *1E6),(int) (longi *1E6)); MControl = mapview.getController(); MControl.animateTo(GeoP); MControl.setZoom(14); MyLocationOverlay LocationOverlay = new MyLocationOverlay(this, mapview); mapview.getOverlays().add(LocationOverlay); LocationOverlay.enableCompass(); LocationOverlay.enableMyLocation(); }//onCreate //Map @Override protected boolean isRouteDisplayed() { return false; }







    <LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tab2"
        android:orientation="vertical"
        android:paddingTop="60px"
         >
        <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0jiwJEbT6if6dhaf0x6Fr_zRLsrz_CYxcLGj6pQ"
                 />

</LinearLayout>

3 个答案:

答案 0 :(得分:1)

您必须创建两个不同的API密钥,一个包含模拟器的调试签名密钥,另一个包含用于为设备签署apk的密钥。

答案 1 :(得分:0)

我认为这两点可能会对你有所帮助。我有类似的问题 -

  1. 尝试将uses-library行放在application标记之后和activity标记之前。这可能是因为在Activity类中引用了库。

  2. 如果这不能解决问题,请尝试检查您的API密钥是否已正确生成。找到位于默认文件夹“C:\ Documents and Settings \\ Local Settings \ Application”中的SDK调试证书Data \ Android“并在Keytool命令中使用此位置路径。您也可以将其复制到“C:\ android”然后运行 'keytool.exe -list -alias androiddebugkey -keystore“C:\ android \ debug.keystore”-storepass android -keypass android'。无论哪种方式都需要正确指定路径。它确实创建了密钥,但在运行应用程序时却没有加载地图。在我重新创建密钥correclty后,我的地图快速加载。

答案 2 :(得分:0)

调试密钥 - 您可以使用它直接从Android Studio或Eclipse调试您的应用程序,使用您的虚拟设备上的google map api或通过USB进行手机/平板电脑。

发布密钥 - 您可以使用它来制作已签名的apk文件,您可以将其安装在任何其他设备上。

如果你想测试你的发布密钥,你需要创建你的应用程序的apk文件并将其安装在你的设备上 - 相信我100%肯定!!!

您不能使用发布密钥来调试(运行地图)应用程序!!!

这就是为什么它叫做Debug and Release:D

相关问题