我在我的谷歌 Map 应用程序上得到一个白色屏幕 - 缩放按钮显示 . 我正在重新审视我去年编写的代码,该代码运行正常,所以它应该都可以 . 我正在测试姜饼2.3.3手机 .
-
我启用了谷歌 Map v2
-
我的清单中有一个匹配的api密钥:AIzaSyCKzmEns8anNV3QLLBRIw3f88Y7TmsXXXX
-
我的调试使用了正确的哈希/域:
D6:35:00:83:CD:F6:2F:69:44:FB:D2:9E:AE:DE:F0:1B:27:01:1D:FF;com.example.androidac_session8a
-
在我的项目中,我链接了google-play-services-lib
-
我已下载谷歌API SDK并将其设置为目标
-
在我的代码中,我检查是否返回了googlemap对象,它是在logcat内部没有生成错误
-
据我所知,我的清单还可以:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.androidac_session8a.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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="AIzaSyCKzmEns8anNV3QLLBRIw3f88Y7TmsXXXX"/>
</application>
- 我的布局位于选项卡式视图中,但这里是xml:
<fragment
android:id="@+id/worldmap"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
- 这是初始化 Map 的代码 . 我有额外的代码来更新它以显示卫星和绘制的东西,但我删除了 .
private void initialiseMap() {
//get the fragment and call getMap on it which returns a GoogleMap
if (googleMap == null) {
googleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.worldmap)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(activity.getApplicationContext(),
"Unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
3 回答
debug keystore可能会在1年内到期 . 虽然没有固定时间限制 . 正如您所说,您的代码已有一年了,所以我认为您的密钥已过期 . 所以最好创建新的apikey . 通常,错误的api密钥会出现白屏问题 .
打开终端并执行以下命令以生成SHA-1指纹 .
在Windows上
在Linux或Mac OS`上
并使用此SHA-1指纹创建新的api密钥
这太糟糕了我可以哭;)
我去度假并关闭了数据包数据 .
我有wifi,但在工作我的wifi热点充其量,但wifi仍然保持,但什么也没做 .
我启用了数据包数据并且工作正常 .
我花了3个小时重新安装eclipse,google play library,重新生成密钥....
我遇到了类似的问题,但我怀疑你会遇到同样的问题,但无论如何都要尝试一下 . 我将默认的LatLng设置为放大到 Map 的开头(0,0)和非常高的缩放级别 . 所以我看到一个高放大水平的沙漠,看起来 Map 根本没有加载 .
因此,请尝试缩小 Map 或尝试在 Map 开头显式设置latLng和缩放级别 .