Android Studio - 发布 apk 的真实 Android 设备上的 Google 地图仍然空白 [英] Android Studio - Google map still blank on real Android device on release apk

查看:23
本文介绍了Android Studio - 发布 apk 的真实 Android 设备上的 Google 地图仍然空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用谷歌搜索,阅读数百万条关于如何生成谷歌 API 密钥、如何使用它的建议,但没有任何效果!

  1. 启用谷歌地图 v2 API
  2. 使用谷歌地图创建一个包含一项活动的项目(工作室中的默认向导)
  3. 在 google 上为调试项目创建了密钥,将应用程序的 SHA1;app 包 分配给了 google 上的项目密钥
  4. API 密钥插入 google_maps_api.xml(AndroidManifest.xml 自动更新)
  5. 构建和在应用运行的 AVD 上运行,显示地图.

那么:

  1. API 已启用
  2. 在 Android Studio 中创建了用于发布的密钥库 (keystore.rel.jks)
  3. 生成的指纹(keytool -list -v -keystore C:DropboxAndroidKeyStorekeystore.rel.jks)
  4. 在 google 上为新发布项目添加了新指纹(发布 SHA1;应用程序包)-密钥生成的 AIza...
  5. API 密钥插入 google_maps_api.xml(AndroidManifest.xml 自动更新)
  6. 生成签名的应用程序(使用 keystore.rel.jks)&在真实设备上安装...应用正在运行,地图仍然空白,只有缩放按钮和 Google 标签处于开启状态

提前感谢您的建议.

兹德内克

解决方案

确保在发布文件夹下的 google_maps_api.xml 中输入您的发布 API 密钥.

首先,使用 Project Explorer 左上角的下拉菜单切换到 Project 视图.然后,展开app/src/,您将看到子文件夹debugrelease.在那里,您应该在 debug/res/valuesrelease/res/values 下看到两个单独的 google_maps_api.xml 文件.

确保发布 API 密钥位于 release/res/values 文件夹下的 google_maps_api.xml 文件中,因为这是用于签名发布 apk 的密钥.

googled it, read millions of advices about how to generate google API key, how to use it but nothing works!

  1. enabled google maps v2 API
  2. created project with one activity with google map (default wizard in studio)
  3. created key on google for debug project, assigned SHA1;app package of application to the project key on google
  4. API key inserted into google_maps_api.xml (AndroidManifest.xml updated automaticaly)
  5. build & run on AVD on which the app is working, map is shown.

Then:

  1. API already enabled
  2. in Android studio created keystore for release (keystore.rel.jks)
  3. generated fingerprints (keytool -list -v -keystore C:DropboxAndroidKeyStorekeystore.rel.jks)
  4. on google added new fingerprint to the new release project (release SHA1;app package) - key generated AIza...
  5. API key inserted into google_maps_api.xml (AndroidManifest.xml updated automatically)
  6. generate signed app (using keystore.rel.jks) & install on real device ... app is working, map is STILL BLANK, only zoom buttons and Google label is on

Thanks in advance for any advice.

Zdenek

解决方案

Make sure you enter your release API key in the google_maps_api.xml under the release folder.

First, switch to Project view by using the dropdown in the upper left of the Project Explorer. Then, expand app/src/, and you will see subfolders debug and release. Under there, you should see two separate google_maps_api.xml files under debug/res/values and release/res/values.

Make sure that the release API key is in the google_maps_api.xml file under the release/res/values folder, since this is the one that will be used for the signed release apk.

这篇关于Android Studio - 发布 apk 的真实 Android 设备上的 Google 地图仍然空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆