Play Store 上发布的应用程序无法与 Google Maps API 和 Facebook API 通信 [英] Published App on Play Store can't communicate with Google Maps API and Facebook API

查看:17
本文介绍了Play Store 上发布的应用程序无法与 Google Maps API 和 Facebook API 通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Android Studio 创建了一个签名的 APK,并将我的 SHA1 指纹和我的应用程序中的相关 api 密钥添加到 Google 开发者控制台和 Facebook 控制台.如果我通过 USB 上传我签名的 apk,一切正常,在安装它之后,地图 API 和 facebook api 运行良好.如果我将相同的 apk 上传到 Play 商店,当我尝试使用 Facebook 登录时,它会显示无效的密钥哈希.密钥哈希 blablabla 与任何存储的..不匹配".因此,如果我在没有 facebook 的情况下登录,我什至无法获取我的谷歌地图;这让我认为 Play 商店中加载的 apk 会改变他的指纹或类似的东西.我检查了 Android Developers 和 Stackoverflow 上的所有内容,但我无法让它工作,因为奇怪的是,这个签名的发布 apk 在我将它加载到 Play 商店之前运行良好.

解决方案

终于解决了,问题可能是release中没有加载api提供的文件google_maps_api.xml,所以我

然后我注册了 2 个不同的密钥,每个密钥都有正确的 sha1 指纹,一个调试,另一个由 Google Play 控制台提供(不是上传证书,而是由 Google 生成的另一个).

非常感谢 Zuhad 和 Andy Developer 的启发.

I created a signed APK with Android Studio, and I added to Google Developer console and Facebook console my SHA1 fingerprint and the relative api keys in my app. Everything works well if I upload my signed apk via USB, after installing it maps API and facebook api works well. If I upload the same apk to the Play Store, when I try to login with Facebook, it says "invalid key hash. The key hash blablabla doesn't match with any stored..". So if I log without facebook, I can't even get my google maps; this leads me to think that the apk loaded on the play store changes his fingerprint or some stuff like that. I checked all the stuff on Android Developers and Stackoverflow, but I can't make it work, because the strange thing is that this signed release apk works well until I load it on the Play Store.

解决方案

I finally solved, the problem was probably that the file google_maps_api.xml provided by the api was not loaded in the release, so i

i did like that:

buildTypes {
    debug {
        manifestPlaceholders = [mapsKey: "AIzaSyB8o9KzQ5YN8U8AFS************"]
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        manifestPlaceholders = [mapsKey: "AIzaSyApLacqgkdIR7uEpcf*****************"]
    }
}

and then in my AndroidManifest

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="${mapsKey}" />

Reference: https://stackoverflow.com/a/33917692/3235560

then i registered 2 different keys each with the right sha1 fingerprint, one debug and the other given by Google Play console (not the upload certificate, but the other one generated by Google).

Very Very thanks to Zuhad and Andy Developer for inspiration.

这篇关于Play Store 上发布的应用程序无法与 Google Maps API 和 Facebook API 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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