简体   繁体   English

Android哈希代码不匹配:实际设备上出现onFacebookError,应用在模拟器上运行

[英]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.

相关问题 Android应用程序可以在模拟器中完美运行,但由于外部数据库而无法在设备上运行 - Android app runs perfectly in emulator but not on device due to external DB MediaPlayer可在模拟器上运行,但不能在android中的实际设备上运行 - MediaPlayer working on emulator, but not on actual device in android Android - OpenGL - 仿真器与实际设备 - Android - OpenGL - Emulator vs Actual Device 应用程序在模拟器上运行正常,但在真实设备上崩溃 - App runs fine on emulator, but crashes on real device 我的Android应用程序在Eclipse模拟器中运行,但未在我的设备上运行 - My android app runs in eclipse emulator but doesn't run on my device Android RadioButton仅显示文本,而不显示设备模拟器中的实际按钮 - Android RadioButton shows only text, not the actual button in device emulator 我的Android应用程序在模拟器上运行,但无法在我的Android设备上运行 - My Android application runs on emulator but not working on my android device Android数据库应用程序在模拟器上运行良好,但在设备上显示错误 - Android database application runs fine on emulator but gives an error on the device Android应用程序无法在设备或模拟器上运行吗? - Android app don't run on the device or emulator? android 应用程序适用于模拟器但不适用于真实设备 - android app works on emulator but not in real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM