如果从Google Play下载了应用,则android facebook登录将停止工作 [英] android facebook login stops working if app is downloaded from google play
问题描述
我将功能全面的应用程序上传到Google Play,从那里下载该应用程序后,facebook登录无法正常进行!!我正确配置了我的Facebook应用程序,并且可以在Eclipse环境中使用.搜索后,由于facebook键哈希,可以完成此操作.但是,我得到的像是:
I uploaded my fully working app on Google Play and when download it from there, facebook login doesn't work!! I properly configure my facebook app and works with eclipse environment. After searching, it can be done due to facebook key hashes. However, I obtained it like:
似乎还必须获得用于分发的密钥哈希...但是如何?谢谢.
Seems that a key hash for distribution must be also obtained... but how? Thank you.
推荐答案
替代1:
将此功能与使用您的发布密钥签名的应用 结合使用. 不是是从Eclipse部署的.
Use this with the app signed with your release key. Not the one that is deployed from Eclipse.
在应用程序的第一个活动中运行以下代码:
Run this piece of code in the first Activity of your app:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"YOUR_PACKAGE_NAME", PackageManager.GET_SIGNATURES);
for (Signature signature: info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.e("FACEBOOK APP SIGNATURE", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
此行:Log.e("FACEBOOK APP SIGNATURE", Base64.encodeToString(md.digest(), Base64.DEFAULT));
将在DDMS中记录密钥哈希.
This line: Log.e("FACEBOOK APP SIGNATURE", Base64.encodeToString(md.digest(), Base64.DEFAULT));
will log the Key Hash in DDMS.
替代2:
- 下载适用于Windows的OpenSSl ,然后将.zip解压缩到一个简单的位置,例如:c:\ openssl,所有zip内容都提取到该文件夹的根目录中.
- 将您的签名密钥文件复制到JRE安装的bin文件夹中.例如,在我的情况下:
C:\Program Files\Java\jre7\bin
- 在复制签名密钥的bin文件夹中,按 SHIFT +右键单击->在此处打开命令窗口.
- 运行此命令:keytool -exportcert -alias YOUR_ALIAS -keystore YOUR_SIGNING_KEY> c:\ openssl \ bin \ debug.txt
- 输入签名密钥的密码
- 现在,导航至c:\ openssl \ bin文件夹并键入以下命令:
- Download OpenSSl for Windows and extract the .zip to a simple location like: c:\openssl with all the contents of the zip extracted in this folder's root.
- Copy your signing key file to your JRE installation's bin folder. For example, in my case:
C:\Program Files\Java\jre7\bin
- While in the bin folder where you copied the signing key, Press SHIFT+ Right Click -> Open command window here.
- Run this command: keytool -exportcert -alias YOUR_ALIAS -keystore YOUR_SIGNING_KEY > c:\openssl\bin\debug.txt
- Enter your password for the signing key
- Now, navigate to the c:\openssl\bin folder and type in the following commands:
openssl sha1 -binary debug.txt > debug_sha.txt
然后
openssl base64 -in debug_sha.txt > debug_base64.txt
完成! debug_base64.txt 包含您的密钥哈希.将其复制到您的应用程序控制台中,一切就绪.
Done! The debug_base64.txt contains your Key Hash. Copy this in your app console and you are all set.
在我的实验中,这两种方法都为我提供了正确的密钥哈希.但是,在少数情况下(而不是随机的情况),第一种选择没有提供正确的密钥哈希,而第二种选择始终有效.看看哪个适合您.
In my experiece, both the methods have given me the correct Key Hash. However, in a few cases (rather random ones), the first alternative did not give the correct Key Hash while the second alternative has always worked. See which works for you.
这篇关于如果从Google Play下载了应用,则android facebook登录将停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!