JavaGoogleMapsAPIv2显示空白地图
我已经设置了一个Android应用程序,以便在谷歌地图上查看一些东西。我使用了Google Maps API v2,并遵循了所有可以找到的设置here。我甚至用我在谷歌网站上申请的密钥注册了这个应用程序
我已经能够运行该活动,但每次打开它,我都会看到一个空白屏幕
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.stullich.tim.woistmeinphoto"
安卓:versionCode="1"
安卓:versionName="1.0" >
<uses-sdk
安卓:minSdkVersion="8"
安卓:targetSdkVersion="18" />
<permission
安卓:name="com.stullich.tim.woistmeinphoto.permission.MAPS_RECEIVE"
安卓:protectionLevel="signature" />
<uses-permission 安卓:name="com.stullich.tim.woistmeinphoto.MAPS_RECEIVE" />
<uses-permission 安卓:name="安卓.permission.INTERNET" />
<uses-permission 安卓:name="安卓.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission 安卓:name="安卓.permission.ACCESS_COARSE_LOCATION" />
<uses-permission 安卓:name="安卓.permission.ACCESS_FINE_LOCATION" />
<uses-permission 安卓:name="com.google.安卓.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
安卓:glEsVersion="0x00020000"
安卓:required="true" />
<application
安卓:allowBackup="true"
安卓:icon="@drawable/ic_launcher"
安卓:label="@string/app_name"
安卓:theme="@style/AppTheme" >
<uses-library 安卓:required="true"
安卓:name="安卓.test.runner">
</uses-library>
<activity
安卓:name="com.stullich.tim.woistmeinphoto.PhotoGalleryActivity"
安卓:label="@string/app_name"
安卓:screenOrientation="landscape"
>
<intent-filter>
<action 安卓:name="安卓.intent.action.MAIN" />
<category 安卓:name="安卓.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity 安卓:name=".FullImageViewActivity"
安卓:screenOrientation="landscape" >
</activity>
<activity 安卓:name=".MapViewActivity"
安卓:screenOrientation="landscape" >
</activity>
<meta-data
安卓:name="com.google.安卓.maps.v2.API_KEY"
安卓:value="Excluded this for now" />
</application>
这是我加载地图的活动
package com.stullich.tim.woistmeinphoto;
import 安卓.os.Bundle;
import 安卓.support.v4.app.FragmentActivity;
import com.google.安卓.gms.maps.SupportMapFragment;
public class MapViewActivity extends FragmentActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.map_view_activity);
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(安卓.R.id.content, fragment).commit();
}
}
我听说没有使用正确的API密钥会导致这个问题,但我现在已经三次检查了密钥,我认为这不是问题所在
# 1 楼答案
这个Akhil也为我解决了这个问题
我正在使用OSX和调试。密钥库位于
$HOME/.android/debugkeystore
。调试的密码。密钥库是Signing in Debug Mode文档中指出的“android”。需要执行keytool来获取SHA1字符串在Google APIs Console中,需要SHA1字符串
A5:38:93:50:7C:EA:55:22:51:1E:BC:EE:AA:A5:6D:A8:6C:B7:16:35
# 2 楼答案
我也遇到了同样的问题,发现我的调试密钥错了。我改了,现在开始工作了