清单文件中的多个Google API键(Android) [英] Multiple Google api keys in manifest file (Android)

查看:233
本文介绍了清单文件中的多个Google API键(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加两个api键,即Google放置api键和google maps api键。
但我无法同时添加两个清单文件。我可以如何实现相同的任何帮助,将不胜感激。
提前致谢。

I am trying to add two api keys i.e Google places api key and google maps api key. But I am not able to add both at same time to manifest file.How can I achieve the same.Any help would be appreciated. Thanks in advance.

我得到的错误是

The error I am getting is


导致:java.lang.RuntimeException:API密钥只能被指定一次。建议您在AndroidManifest.xml的元素中使用名称为com.google.android.geo.API_KEY的元数据标记

Caused by: java.lang.RuntimeException: The API key can only be specified once. It is recommended that you use the meta-data tag with the name: com.google.android.geo.API_KEY in the element of AndroidManifest.xml

我包含这样的api键

I am including api keys like this

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

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="xxxx"/>


推荐答案

在清单中使用以下元数据。如果你已经有谷歌地图的API密钥,则不需要为地方API创建另一个API密钥。
如果您同时使用Maps&在应用程序中放置Api,然后您只需指定geo api key并仅启用Places Api即可。

Use following meta-data in your manifest. there is no need to create another api key for places api if you already have api key for google map. If you are using both Maps & Places Api in your application then you only need to specify geo api key.and just enable Places Api.

<meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="api_key" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

这篇关于清单文件中的多个Google API键(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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