Android Google Place Picker在Signed APK中工作,但在Live app中不工作 [英] Android Google Place Picker working in Signed APK but not working in Live app

查看:102
本文介绍了Android Google Place Picker在Signed APK中工作,但在Live app中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用了Google Place Picker的应用程序.我面临一个非常奇怪的问题.当我使用应用程序的密钥库创建签名的APK时,Place Picker运行良好.我通过Google PlayStore上传的同一APK.当我打开那个地方选择器时,它会自动关闭.我已经在线阅读了很多评论,也可以在此处阅读.但是我无法确定为什么它在签名的APK和通过Google PlayStore的同一个APK上不能正常工作.

I have an application in which i have used Google Place Picker. There is very strange issue i am facing. When i am creating signed APK with my app's keystore, Place Picker is working very well. That same APK I have uploaded over Google PlayStore. When I come to open that Place Picker it automatically closed down. I already read a lots of comments online and also here in SO. But I can not determine why its working well in signed APK and the same APK which is over Google PlayStore is not working.

当我检查Google PlayStore的LIVE应用程序的日志时,出现这样的错误:

When i checked logs of LIVE application of Google PlayStore it giving error like this :

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 Developer Console中检查了我的密钥是否相同.我还检查了我从KeyStore文件创建的SHA.一切都很好(否则,如果那里有任何错误,它将也无法在Signed APK中使用).

I already have checked into my Google Developer Console that my key is same or not. I also check my SHA which I have created from my KeyStore file. And all are good (Otherwise it will also not works in Signed APK if anything wrongs there).

这是我从活动"中致电地点选择器"的方式

Here is how I calling Place Picker from my Activity

int PLACE_PICKER_REQUEST = 999;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);

这是我的AndroidManifest.xml文件,在其中我将我的API密钥提供给了应用程序标记中的元数据.

Here is my AndroidManifest.xml file where i have give my API key in meta data which is into application tag.

<?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密钥一样,所以我从发行包中删除了整个值包.

There is file which i deleted "release/values/google_maps_api.xml" which is automatic generated. As i already mentioned my API key into string.xml, So I deleted this whole values package from release package.

有人可以告诉我这是怎么回事吗?

Can anyone tell me what is wrong with this?

推荐答案

花了几天的时间寻找该问题的解决方案.终于我找到了解决方案.这是因为 Google Play应用签名

After several days of investing time for finding solution of this problem. Finally I got the solution. It is because of Google Play App Signing .

使用Google Play应用签名:您使用上传密钥对应用进行签名. 然后,Google验证并删除上传密钥签名.最后, Google使用您提供的原始应用签名密钥对应用进行重新签名 并将您的应用交付给用户.

With Google Play App Signing: You sign your app with your upload key. Then, Google verifies and removes the upload key signature. Finally, Google re-signs the app with the original app signing key you provided and delivers your app to the user.

因此,当我为适用于Android的Google Places API"创建API密钥时,我已经使用我的软件包名称和Signed APK的KeyStore的SHA-1对该密钥进行了限制.

So, when I Created API key for "Google Places API for Android" I have restricted that key using my package name and my SHA-1 of Signed APK's KeyStore.

现在该文件位于上传证书"下,因此未使用,因为我必须将我的应用程序唱歌证书的SHA-1传递给Google Developer Console.这样做之后,我的Google PlayStore实时应用程序的Google PlacePicker运行良好.

Now that is under "Upload Certificate" and it is not used, as I have to pass my App Singing Certificate's SHA-1 to Google Developer Console. And after doing that my Google PlayStore's live app's Google PlacePicker working well.

这篇关于Android Google Place Picker在Signed APK中工作,但在Live app中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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