【发布时间】:2017-09-19 18:28:51
【问题描述】:
我有一个使用 Google Place Picker 的应用程序。我面临一个非常奇怪的问题。当我使用我的应用程序的密钥库创建签名的 APK 时,Place Picker 运行良好。我通过 Google PlayStore 上传的同一个 APK。当我打开那个地方选择器时,它会自动关闭。我已经在网上和 SO 中阅读了很多 cmets。但我无法确定为什么它在签名的 APK 中运行良好,而在 Google PlayStore 上的同一个 APK 无法运行。
当我检查 Google PlayStore 的 LIVE 应用程序日志时,它给出了这样的错误:
Volley : [198] BasicNetwork.performRequest: Unexpected response code 403
for https: //www.googleapis.com/placesandroid/v1/search?key=MY_KEY/ ? V / ConnectivityManager : isActiveNetworkMetered() returns: true
/ ? E / AsyncOperation : serviceID = 65, operation = SearchPlaces
OperationException[Status {
statusCode = PLACES_API_INVALID_APP, resolution = null
}]
我已经在我的 Google 开发者控制台中检查了我的密钥是否相同。我还检查了我从 KeyStore 文件创建的 SHA。一切都很好(否则,如果那里有任何问题,它也不会在签名 APK 中工作)。
这是我从我的活动中调用 Place Picker 的方式
int PLACE_PICKER_REQUEST = 999;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
这是我的 AndroidManifest.xml 文件,其中我在元数据中提供了我的 API 密钥,该密钥位于应用程序标签中。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example" >
// ALL PERMISSIONS ARE HERE
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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.geo.API_KEY"
android:value="@string/MY_KEY" />
</application>
</manifest>
我删除了自动生成的“release/values/google_maps_api.xml”文件。正如我已经在 string.xml 中提到了我的 API 密钥,所以我从发布包中删除了整个值包。
谁能告诉我这是怎么回事?
【问题讨论】:
-
我已经参考了您给定的链接。但是不明白为什么Google 创建一个.xml 文件ane 的时候是在哪里创建的呢?还有我必须做什么才能停止创建这个新的 xml 文件?
标签: android google-maps key google-places-api developer-console