小编use*_*849的帖子

管理Google Maps API密钥

我的应用程序使用了大量的MapView屏幕,我正在试图弄清楚如何在调试环境和生产之间管理API密钥.显然,没有办法在Eclipse中更改调试应用程序密钥,因此我必须在该环境中使用调试映射API密钥.相反,如果没有生产应用程序密钥,就无法导出用于beta测试的软件包,因此我必须在每个视图中更改map API密钥以创建工作包.

我的第一个想法是这样做:

所有MapView.xml文件都有:

android:apiKey="@string/googleMapsAPIKey"
Run Code Online (Sandbox Code Playgroud)

然后在strings.xml中我把它:

<string name="googleMapsPIKey">@string/debugGoogleMapsAPIKey</string>
<string name="debugGoogleMapsAPIKey">TheMagicKeyString</string>
Run Code Online (Sandbox Code Playgroud)

如果这样做,它将允许我在strings.xml中更改单行,并且所有MapView将在重建中更新.但它没有用.我猜strings.xml不能自己引用.还有其他想法吗?

谢谢

android google-maps api-key

4
推荐指数
2
解决办法
5904
查看次数

标签 统计

android ×1

api-key ×1

google-maps ×1