【问题标题】:Google Map only showing Grey Blocks on load - Debug Cert has been obtained谷歌地图仅在加载时显示灰色块 - 已获得调试证书
【发布时间】:2010-05-26 15:42:24
【问题描述】:

我正在尝试遵循 Android 视图教程下的 Google 地图视图。我一步一步跟着看,但还是只能看到灰块。

首先:我使用“Google API's(Google Inc.) Platform 2.2 API Level 8”创建了一个虚拟设备 第二:在创建我的项目时,我选择了“Google API's Google Inc. Platform 2.2 API Level 8”。 第三:我获得了SDK调试证书 第四:开始编码。 Main.xml

<?xml version="1.0" encoding="utf-8"?> 
<com.google.android.maps.MapView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/mapview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:clickable="true" 
android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ" 

/>

HelloGoogleMaps.java

package com.example.googlemap;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.maps.MapView;
import com.google.android.maps.MapActivity;

public class HelloGoogleMaps extends MapActivity 
{
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main);
}

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

}

HelloGoogleMaps 清单:

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

  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="com.google.android.maps" />

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

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

 </manifest> 

有什么想法吗??

谢谢!

【问题讨论】:

    标签: android google-maps


    【解决方案1】:

    您可以尝试在 XML 中更早地提升您的权限 -- see here for a sample manifest 适用于 Android 2.1 及更早版本(尚未在 2.2 上尝试过)。

    另外,请确保您的模拟器确实可以访问 Internet。您应该会在状态栏中看到一个“3G”图标,其中有两条信号强度。相反,如果您的图标中没有条形和“X”,则模拟器在您启动时未能检测到 Internet 连接,因此它模拟没有连接。

    您可能还希望尝试打开常规地图应用程序,看看它是否可以在您的模拟器上运行。如果没有,则可能是防火墙问题阻止了您访问地图切片服务器。

    【讨论】:

    • 感谢您的回复,我移动了示例中显示的权限,并确保状态栏有连接。重新启动模拟器后,我收到了相同的结果,灰色块,没有别的。还有其他想法吗?谢谢!
    • 这可能是一个线索,在它所在的 Eclispe 调试器中:[2010-05-26 12:15:07 - HelloGoogleMaps] 尝试将调试器连接到端口上的“com.example.googlemap” 8699 即使状态栏显示 3G 并且有 2 个栏,这可能是连接问题吗?
    • 您是否尝试过内置的地图应用程序?如果有连接问题,它也会影响它。
    • 很抱歉忽略了这一点,是的,内置地图应用程序确实有效。
    • 然后不知何故你的 API 密钥搞砸了。它看起来像是一组结构合理的乱码,但如果 Maps 有效,那么 API 密钥是我能想到的唯一会导致您出现症状的东西。
    【解决方案2】:

    API 密钥错误。再次提取debug.keystore - 这是为了您的方便:

    "C:\Program Files (x86)\Java\jre6\bin\keytool.exe" -list -alias androiddebugkey -keystore "c:\Users\user\\.android\debug.keystore" -storepass android -keypass android
    

    当然,在 Windows 上将 user 更改为您的用户名。

    在我重新创建 API 密钥之前,我遇到了同样的问题。

    它应该工作:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-16
      • 2019-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多