android - 谷歌地图应用程序不显示 map

标签 android google-maps google-maps-android-api-2

当我运行我的应用程序(谷歌地图应用程序)时,我看不到 map 。我只看到一个白屏(如下图所示)。

主要内容

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.williamroma.example"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

          <!--  Add Google Map Library -->
        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name=".GoogleMapActivity"
            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>

      <!-- Allow to connect with internet -->
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

Activity

package com.williamroma.example;

import com.google.android.maps.MapActivity;

import android.app.Activity;
import android.os.Bundle;

public class GoogleMapActivity extends MapActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

这是我看到的屏幕,我想看这个教程中的 map http://www.androidhive.info/2012/01/android-working-with-google-maps/ enter image description here

布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="AIzaSyCyk2MVC5Fyl7HIB3iHlPgyRqvOF-VXYJw"
/>

</RelativeLayout> 

编辑

我在 logcat 中以橙色显示这些消息

03-31 11:31:16.140: I/Process(1787): Sending signal. PID: 1787 SIG: 9
03-31 11:31:40.940: I/MapActivity(1832): Handling network change notification:CONNECTED
03-31 11:31:40.940: E/MapActivity(1832): Couldn't get connection factory client
03-31 11:31:41.011: D/dalvikvm(1832): GC_CONCURRENT freed 170K, 4% free 9316K/9607K, paused 8ms+6ms
03-31 11:31:41.011: W/CursorWrapperInner(1832): Cursor finalized without prior close()
03-31 11:31:41.011: W/CursorWrapperInner(1832): Cursor finalized without prior close()
03-31 11:31:41.020: D/gralloc_goldfish(1832): Emulator without GPU emulation detected.
03-31 11:31:42.470: W/System.err(1832): IOException processing: 26
03-31 11:31:42.470: W/System.err(1832): java.io.IOException: Server returned: 3
03-31 11:31:42.490: W/System.err(1832):     at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
03-31 11:31:42.490: W/System.err(1832):     at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
03-31 11:31:42.500: W/System.err(1832):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
03-31 11:31:42.500: W/System.err(1832):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
03-31 11:31:42.520: W/System.err(1832):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
03-31 11:31:42.520: W/System.err(1832):     at java.lang.Thread.run(Thread.java:856)

最佳答案

从外观上看,您的代码适用于 Google Map API V1。所以你的 key 一定有问题。据我所知,如果它是新生成的 key ,那么 Google 不会为 Google Map API V1 提供 key ,因此它必须是 Google Map API V2 的 key ,这就是它不起作用的原因。

如果您想将应用程序实现更改为 Google Maps API V2,您可以使用我编写的本指南以及执行此操作的步骤:

Google Maps API V2

关于android - 谷歌地图应用程序不显示 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15728203/

相关文章:

android - 检测两个多边形是否有共同区域

android - Facebook SDK 与 Android 中的 fragment 集成?

android - Bing map - Google map 坐标差异

android - 在 android 中使用 Map API V2 在 map 上添加搜索栏

google-maps - 谷歌地图 iframe 禁用移动设备上的滚动触摸

android - 调试和 Release模式的 SHA-1 证书是否不同?

Android 谷歌地图摆脱折线

java - 通过 Intent 从 Android 应用程序以编程方式在 Facebook 中共享图像

android - 如何使用 EditText 在 Android 中检索字符串?

android - ExoPlayer AudioTrack 口吃