Search code examples
androidfacebookfacebook-android-sdk

Facebook SDK issues with app name mismatch while trying to share via Android app


I'm having the hardest time getting the Facebook sdks integrated with my android app. All I want to do is utilize the sharing feature of the sdk.

I get the following error:

I'm currently have my gradle configured to compile 'com.facebook.android:facebook-android-sdk:3.21.1'

String.xml

 <string name="app_name">TestApp</string>
 <string name="facebook_app_id">123456789</string>

With in my AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
   <application
        android:allowBackup="true"
        android:icon="@drawable/mtr_icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:name="com.test.Application"
        android:hardwareAccelerated="true">



    <activity
        android:name="com.test.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <activity android:name="com.facebook.LoginActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:label="@string/app_name" />

    </application>

</manifest>

Code for sharing:

  // Publish the post using the Share Dialog
 FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(_activity)
.setApplicationName("TestApp")
.build();

Within the actual Facebook Dashboard:

 - Google Play Package Name = com.test
 - Class Name = com.test.MainActivity
 - Display Name = TestApp
 - App ID = 123456789
 - Also added the keyHashes to the keystore that is used to sign the generated apt

Note: The TestApp is stated "This app is in development mode" within the Facebook dashboard.

When I run the application, I get the error when it tries to share the information and get the exception:

Error: com.facebook.FacebookException: Failed to authenticate the application because of app name mismatch. Please check the application name configured by the dialog.

  1. I can't figure out what i'm doing wrong because the app name "TestApp" matches the "Display Name" under the Facebook ->Settings -> Display Name "TestApp". I've verified that the appId is the same as well.
  2. Does that Facebook app need to be published and is this why i'm having issue? I only want to use the sdk so that the native android app can post to Facebook.
  3. Is there anything else i'm just not seeing.

I followed the instructions here: https://developers.facebook.com/docs/android/getting-started#maven

Any advice appreciated! Thanks, Derek


Solution

  • So I figured it out. The error message was misleading. The Facebook app needs to be logged in as a user that is one of the Facebook Roles (Admin, Developer, Test, etc) if the Facebook app is not public yet.