Ron*_*shi 3 android google-maps key google-places-api developer-console
我有一个应用程序,其中我使用了Google Place Picker.我面临着一个非常奇怪的问题.当我使用我的应用程序的密钥库创建签名APK时,Place Picker工作得非常好.我通过Google PlayStore上传了相同的APK.当我打开Place Picker时它会自动关闭.我已经在网上阅读了很多评论,也在SO中.但是我无法确定为什么它在签名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
}]
Run Code Online (Sandbox Code Playgroud)
我已经在我的Google Developer Console中检查过我的密钥是否相同.我还检查了我从KeyStore文件创建的SHA.一切都很好(否则它也不适用于签名APK,如果有任何错误).
以下是我从我的Activity中调用Place Picker的方法
int PLACE_PICKER_REQUEST = 999;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
Run Code Online (Sandbox Code Playgroud)
这是我的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>
Run Code Online (Sandbox Code Playgroud)
有删除了自动生成的"release/values/google_maps_api.xml"的文件.正如我已经将我的API密钥提到了string.xml中,所以我从发布包中删除了整个值包.
谁能告诉我这有什么问题?
Ron*_*shi 10
经过几天的投入时间来寻找这个问题的解决方案.最后我得到了解决方案.这是因为Google Play App Signing .
使用Google Play应用程序签名:您使用上传密钥对应用进行签名.然后,Google会验证并删除上传密钥签名.最后,Google会使用您提供的原始应用签名密钥重新签名该应用,并将您的应用交付给用户.
因此,当我为"Google Places API for Android"创建API密钥时,我使用我的软件包名称和签名APK的KeyStore的SHA-1限制了该密钥.
现在这是在"上传证书"下并且没有使用,因为我必须将我的App歌曲证书的SHA-1传递给Google Developer Console.在这之后我的Google PlayStore的实时应用程序的Google PlacePicker运行良好.
| 归档时间: |
|
| 查看次数: |
929 次 |
| 最近记录: |