谷歌地图在Android应用 [英] Google maps in an android app

查看:152
本文介绍了谷歌地图在Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着添加谷歌地图到我的应用程序。
香港专业教育学院增加了API密钥插入清单

Im trying to add google map into my app. Ive added the API key into the manifests

 <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyAoWtqYmkOh4******8sNehbI8APKNnI08" />

也是premissions:

and also the premissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

当我运行在调试模式(和MTP模式)我的手机上的应用程序
在地图上示出..
但是当我生成APK文件,然后手动安装,地图犯规表演。

when i run the app on my phone in debug mode (and MTP mode) the map is shown.. but when i generate the apk file and install it manually, the map doesnt show.

这是什么问题?

推荐答案

您必须添加释放键(这样你才会有两把钥匙一为调试,另一个用于RELASE)

you have to add the release key (so you will have two keys one for debug and the other for relase)

的答案就在这里
生成谷歌地图发布API密钥

确定这里是什么,XML包含

ok here is what that xml contains

    <?xml version="1.0" encoding="utf-8"?>
<resources> 
    <string name="google_maps_key" templateMergeStrategy="preserve">AIzaSyB_______THE_KEY______corZYhm_pmI</string>

</resources>

和manifest文件中添加这

and in the manifest file add this in

   <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_key" />

在资源管理器中打开您的应用程序并创建一个release文件夹,并把包含释放钥匙在这里的应用程序的\\ src \\释放你的XML \\资源\\值

open your app in explorer and create a release folder and put your xml containing the release key here app\src\release\res\values

和这里包含调试关键应用程序的\\ src \\调试XML \\ RES \\值

and the xml containing the debug key here app\src\debug\res\values

这篇关于谷歌地图在Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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