0

While trying to use Facebook SDK on my Android App, I got this error:

"03-12 17:53:27.607: E/Activity(27797): Error: com.facebook.FacebookException: Failed to authenticate the application because of app name mismatch. Please check the application name configured by the dialog."

I have already read all the post about this issue checked my app setting in Facebook as well as in my app but nothing is resolving this issue.

These are the links I have already followed

Android + Facebook SDK : "Failed to authenticate the application because of app name mismatch."

Android - Facebook connectivity fails

These are the setting in my Facebook dashboard

  • Display name: Abc Def
  • Namespace: blank (nothing is filled here)
  • Google Play Package Name: com.xyz.abcdef
  • Class name: GameAcivity
  • Keyhash: it has been put there(if that has been an issue logcat would have shown it as keyhash issue)
  • Single sign on is enabled (But I am not asking user to login just for the share dialog as it is not required according to FB documentation)

I am trying to use this share dialog on my own device with my own Facebook account which is the administrator of the app as well.

In my Project:

  • Project name: AbdDef
  • app_name: Abd Def (in android manifest)

And this is the code I am using:

FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
            .setLink("https://developers.facebook.com/android")
            .setApplicationName("Abc Def")
            .build();
uiHelper.trackPendingDialogCall(shareDialog.present());

I have carefully watched over caps as well as spaces. Can someone point out if I am doing something wrong. It would be a great help.

Community
  • 1
  • 1
Rohit Goyal
  • 1,521
  • 3
  • 24
  • 49
  • "I have already read all the post about this issue checked my app setting in Facebook as well as in my app but nothing is resolving this issue." -- please detail what you did here, so folks won't be either forced to "read all the posts" or wind up giving you duplicate advice. – 323go Mar 12 '15 at 12:57
  • 2 possible causes: **hash**, you need a hash for your release key and another for your debug key. **package name** double check that the package name on Facebook dashboard is the same on your manifest or `build.gradle` – Budius Mar 12 '15 at 14:11
  • Try removing the setApplicationName and see if that works. `setApplicationName` is an optional parameter used for an optimization, and is not required. – Ming Li Mar 12 '15 at 16:58
  • @323go Updated the SO links I have already tried. Thanks. – Rohit Goyal Mar 13 '15 at 11:20
  • @Budius Double checked hash key and package name.They are correct. – Rohit Goyal Mar 13 '15 at 11:20
  • @MingLi If I remove 'setapplicationname' then I get the following error. com.facebook.FacebookException: Failed to get app name. – Rohit Goyal Mar 13 '15 at 11:21
  • Are you setting the application ID anywhere (either in your manifest or in code)? Are you trying to share from a user who's doesn't have a role in your app, and your app isn't public yet? – Ming Li Mar 13 '15 at 16:54
  • @MingLi Yes. I have put the app id in res/values/strings.xml file as mentioned in documentation like this.. MY_APP_ID I using m own account which is an admin account. The app is public but it shouldn't matter as I am using admin account. – Rohit Goyal Mar 14 '15 at 10:02
  • 1
    I don't think you're adding your app id correctly. The "com.facebook.sdk.ApplicationId" should be a meta-data element in your AndroidManifest.xml, and then set the "facebook_app_id" in your strings.xml file. See the last steps here: https://developers.facebook.com/docs/android/getting-started#androidstudio – Ming Li Mar 16 '15 at 02:23
  • @MingLi That was precisely the issue. It is a little miss-leading on facebook for eclipse setup. You can write an answer and I will accept that. :) Thanks again. :) – Rohit Goyal Mar 16 '15 at 09:22
  • @MingLi Can you also tell me if there is a way to write the callback function for this. What I want to know is whether the sharing was successful or not. – Rohit Goyal Mar 17 '15 at 10:09
  • See https://developers.facebook.com/docs/android/share#linkshare-handlingresponses – Ming Li Mar 17 '15 at 16:38

1 Answers1

1

You need to add the "com.facebook.sdk.ApplicationId" as a meta-data element in your AndroidManifest.xml, and then set the "facebook_app_id" in your strings.xml file.

See the last steps here: developers.facebook.com/docs/android/

Ming Li
  • 15,672
  • 3
  • 37
  • 35