Android Facebook SDK 3.0 gives "remote_app_id does not match stored id" while logging in

I'm trying to build a app that uses Facebook SDK for Android 3.0. But when I'm trying to call

Session.openActiveSession

It just simply gives me a SessionState with CLOSED_LOGIN_FAILED, and LogCat is:

12-16 00:03:40.510: W/fb4a:fb:OrcaServiceQueue(4105): com.facebook.orca.protocol.base.ApiException: remote_app_id does not match stored id 

I have searched StackOverflow with "remote_app_id" and the results are the "Bundle ID" in iOS, but I don't know what does the "remote_app_id" means in Android. I have already set the package name and the activity name in my Facebook app settings. I have no idea of the reason of the error.

Answers


Another possible error (which happened with me) is: to set up a "Key Hash" at Facebook App Console and to sign the android app using another keystore.

Unfortunately this is caused because Facebook Getting Started Tutorial induces this error. It says that android developers should use default android debug key in your examples and doesn't explain that the Key Hash should be generated with the same keystore you will sign your application.

My recomendation is to set up two Key Hashes at your facebook console:

  1. default android debug key:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

  1. your application release key:

keytool -exportcert -alias yourappreleasekeyalias -keystore ~/.your/path/release.keystore | openssl sha1 -binary | openssl base64

Remember: you cannot publish an application that is signed with the debug key generated by the SDK tools. So it isn't possible to publish an app using only the hash key generated using the first previous command line (as facebook tutorial suggests.

For more information about signing your application, visit Signing Your Application.


Another option is to print out the key hash sent to Facebook and use that value.

Make the following changes to the onCreate() method in your main activity:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
          "com.facebook.samples.loginhowto", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures){
           MessageDigest md = MessageDigest.getInstance("SHA");
           md.update(signature.toByteArray());
           Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

Replace com.facebook.samples.loginhowto with your own package name.

This worked for me!


I solved this question. The problem is, the "Key Hash" which I generated using "keytool" was wrong. When the "keytool" prompts for a password, you have to use "android" for it (without quotes). I was using my own password instead. When I changed my password, the problem just flew away. Hope this helps.


I've got trapped by wrong openssl, that generated wrong hash key. i used openssl from http://gnuwin32.sourceforge.net/packages/openssl.htm that solved the problem.


I had the same problem, found out that the openssl was creating the wrong sha1. downloaded a new one and it worked like a charm.


Also, make sure that you enter the hash in the correct place in the facebook dev portal. Edit application settings and select Native Android App.

I had mistakenly put the hash in the 'Sample App Settings' instead.


You are getting the hash-key with debug key... Which may work if you haven't sign the package and running app in debug mode. What you need to do is :

1) Go to the manifest file and add to the application android:debuggable="true".

2) Now run your app and monitor the logcat.

3) You will get printed a new key which will be the matching key with x9SLcMXBlgly1f36PJuuc4a3YAc, The key you have got is now having a = sign in the last.

4) Register this key on facbook developer site

Alternate Trick

You can do one other thing Simply register this key to the facebook developers site x9SLcMXBlgly1f36PJuuc4a3YAc=

Just add = to the key which is being shown by the facebook app.

you are done!! Hope this will work.


Need Your Help