[英]Android Hash code Mismatch : onFacebookError on actual device, app runs on emulator
and thanks in advance for your time and attention! 在此先感谢您的时间和关注!
My android app that uses the facebook sdk runs nicely on the emulator, but i get onFacebookError() on both Samsung Galaxy S1 and S2 devices. 我使用facebook sdk的android应用程序在模拟器上运行良好 ,但是我在Samsung Galaxy S1和S2设备上都遇到了onFacebookError() 。 I wish I could also supply you with more detailed error output information, but I currently do not have those devies at hand to debug on them and check whats going wrong with adb logcat.
我希望也可以为您提供更详细的错误输出信息,但是我目前没有手头的工具可以对其进行调试并检查adb logcat出了什么问题。 I know onFacebookError() method is running because of a Toast i put there displaying "onFacebookError".
我知道onFacebookError()方法正在运行,因为我放了一个Toast,显示“ onFacebookError”。
Until i manage to get those phones and investigate the errors and post them here, anyone encountered this issue before? 在我设法获得这些电话并调查错误并将其发布到此处之前,有人曾遇到过此问题吗? When i searched here for this problam I read someone thinks this is because the official facebook app is installed on the devices.
当我在这里搜索该问题时,我读到有人认为这是因为设备上已安装了官方Facebook应用程序。 Is this relevent?
这是无关紧要的吗?
Toasting e.getMessage() to get the error details like this: 敬酒e.getMessage()以获得类似以下的错误详细信息:
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
//Toast.makeText(MemoFriendActivity.this, "fbError", Toast.LENGTH_SHORT).show();
Toast.makeText(MemoFriendActivity.this, "MSG: "+e.getMessage()+ " CODE: "+e.getErrorCode(), Toast.LENGTH_LONG).show();
}
Displayed this message on S2 devices: "MSG: ivalid_key:Android key mismatch. Your key "XXX" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers CODE: 0" 在S2设备上显示此消息:“ MSG:ivalid_key:Android密钥不匹配。您的密钥“ XXX”与您的应用程序设置中指定的允许密钥不匹配。请在http://www.facebook.com/developers CODE上检查您的应用程序设置:0“
Code: 码:
public void onClick(View v) {
// TODO Auto-generated method stub
if (MyUtil.fb.isSessionValid())
{
//button close session - log out of facebook
try {
MyUtil.fb.logout(getApplicationContext());
updateGuiAccordingToState();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
//login to facebook
MyUtil.fb.authorize(this, new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(MemoFriendActivity.this, "fbError", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
Toast.makeText(MemoFriendActivity.this, "OnError", Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor editor = sp.edit();
editor.putString("access_token", MyUtil.fb.getAccessToken());
editor.putLong("access_expires", MyUtil.fb.getAccessExpires());
editor.commit();
getUsername();
updateGuiAccordingToState();
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
Toast.makeText(MemoFriendActivity.this, "OnCancel", Toast.LENGTH_SHORT).show();
}
});
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
MyUtil.fb.authorizeCallback(requestCode, resultCode, data);
}
My.Util.fb is a static Facebook object. My.Util.fb是静态的Facebook对象。 Again, this code works on the emulator.
同样,此代码可在仿真器上运行。 Anybody knows how to solve it on a device?
有人知道如何在设备上解决它吗? I hope I can look it up on a device soon and share.
希望我能尽快在设备上查找并分享。
Ok, got the answer myself. 好吧,我自己得到答案。 This is a mismatch of the android key.
这是android键的不匹配。 when running the app from a device instead of the emulator, you need to replace the Hash key that you got on your development PC to the one of the app on the phone has, which you can get from the output of e.getMsg like i showed here.
从设备而不是模拟器运行应用程序时,需要将开发PC上获得的Hash密钥替换为手机上的应用程序之一,您可以从e.getMsg的输出中获取该密钥,例如i显示在这里。 get the key from your device, and set it up as the new Hash in facebook.com/developers.
从您的设备中获取密钥,并将其设置为facebook.com/developers中的新哈希。 You can also add this hash key in addition to the one you have of your PC in case you want the app to work on both phone and PC.
如果您希望该应用程序在手机和PC上都可以运行,则除了您的PC之外,还可以添加此哈希密钥。 Hope this helps others.
希望这对其他人有帮助。
如果能够在设备上看到祝酒词,则敬酒e.getMessage()
值以查看更详细的错误报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.