Android Facebook remote_app_id does not match stored id Error

前端 未结 1 1091
刺人心
刺人心 2020-12-05 08:54

In my application user have to login via facebook, but i am getting this error,

**my logcat error:**

02-14 18:00:01.821: WARN/fb4a:fb:OrcaServiceQueue(10988         


        
相关标签:
1条回答
  • 2020-12-05 09:28

    In the main Activity of your application, in the onCreate(), put this code and run the app.

    This will give you the correct Key Hash that is needed by Facebook. Apparently, JRE 1.7 does that occasionally.

    Copy the result that will be displayed in the logcat trace and paste in your App's Facebook console and you should be good to go.

    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "ENTER.YOUR.PACKAGE.NAME", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("MY KEY HASH:",
                    Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e) {
    
    } catch (NoSuchAlgorithmException e) {
    

    EDIT: Almost forgot. Don't forget to replace the ENTER.YOUR.PACKAGE.NAME with your app's package name. ;-)

    UPDATE:

    Solution 1:

    Try this link: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1. I found that using the Facebook method of getting a Hash Key did not always work as advertised. This link however, has a different method of getting the Hash Key and has pretty much always worked.

    Solution 2:

    That being said, I always found the simplest thing to do was, let the Facebook SDK tell you what your Hash Key is. This is by far more simpler and shouldn't take more than a couple of minutes.

    Step 1: In your Facebook SDK, locate the Util.java class. In that, change this:

    private static boolean ENABLE_LOG = false;
    

    to:

    private static boolean ENABLE_LOG = true;
    

    Step 2: Create a new Signed APK, transfer to your device and install. If it is already installed, naturally, it will prompt.

    Step 3: With your DDMS (Logcat) running and your device connected to the computer, run the application and keep looking for a key mismatch warning. That warning has the actual Hash Key. Copy that key, go to your Facebook Developer page and add the new key to the list.

    0 讨论(0)
提交回复
热议问题