Skip to main content

Prerequisites

Before setting up the Android SDK:

Configuration

1

Add Facebook App ID to strings.xml

Open or create android/app/src/main/res/values/strings.xml and add your Facebook credentials:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Your App Name</string>
    <string name="facebook_app_id">YOUR_FACEBOOK_APP_ID</string>
    <string name="fb_login_protocol_scheme">fbYOUR_FACEBOOK_APP_ID</string>
    <string name="facebook_client_token">YOUR_CLIENT_TOKEN</string>
</resources>
Replace:
  • YOUR_FACEBOOK_APP_ID with your Facebook App ID
  • YOUR_CLIENT_TOKEN with your Facebook Client Token (found in Facebook Developers > Settings > Advanced)
2

Update AndroidManifest.xml

Add the following to your android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    
    <application>
        <!-- Add this meta-data inside the application tag -->
        <meta-data 
            android:name="com.facebook.sdk.ApplicationId" 
            android:value="@string/facebook_app_id"/>
        
        <meta-data 
            android:name="com.facebook.sdk.ClientToken" 
            android:value="@string/facebook_client_token"/>
        
        <!-- Your other configuration -->
    </application>
    
    <!-- Add internet permission if not already present -->
    <uses-permission android:name="android.permission.INTERNET"/>
    
</manifest>
3

Generate and add Key Hash

You must generate and add your key hash to Facebook Developer Console for Facebook login to work, especially when the Facebook app is installed on the device.
Generate the key hash for your debug keystore:

For macOS/Linux:

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

For Windows:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

For Release Builds:

Point the command to your app’s release keystore file. You can find its location by checking the storeFile property in android/app/build.gradle:
keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore /path/to/your/release.keystore | openssl sha1 -binary | openssl base64

For Google Play App Signing:

If Google is signing your releases, you’ll need to get the SHA-1 from the Play Console and convert it.
  1. Go to Play Console
  2. Navigate to Release > App signing > App signing key certificate
  3. Copy the SHA-1 certificate fingerprint
  4. Convert it to Base64:
echo YOUR_SHA1_HERE | xxd -r -p | openssl base64
For internal testing: Repeat the process for the SHA-1 from Release > Internal app sharing > Internal test certificate.

Add Key Hash to Facebook:

  1. Go to Facebook Developers
  2. Select your app
  3. Go to Settings > Basic
  4. Scroll down to Key Hashes
  5. Add the generated hash(es)

Manual Linking (React Native < 0.60)

For React Native versions below 0.60, manual linking is required. Consider upgrading to a newer version of React Native.
1

Update settings.gradle

Add to android/settings.gradle:
include ':react-native-fbsdk-next'
project(':react-native-fbsdk-next').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk-next/android')
2

Update app/build.gradle

Add to android/app/build.gradle:
dependencies {
   // ... other dependencies
   implementation project(':react-native-fbsdk-next')
}
3

Update MainApplication.java

Add the import at the top:
import com.facebook.reactnative.androidsdk.FBSDKPackage;
Add the package to the list:
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new FBSDKPackage() // <- Add this
    );
}

Troubleshooting

Cannot run the Android project

Possible causes:
  1. You didn’t add the required configuration to strings.xml and AndroidManifest.xml
  2. You didn’t set up a Facebook app properly
  3. Your Facebook App ID or Client Token is incorrect
Solution: Double-check all configuration steps above.

”Error logging you into this application” when using Facebook app

This typically means the appropriate signing certificate hash hasn’t been saved to your Facebook app.
Follow the key hash generation steps in Step 3 above and ensure:
  • You’ve generated the hash from the correct keystore (debug vs release)
  • The hash has been added to your Facebook app’s Key Hashes section
  • If using Google Play App Signing, you’ve added both the App signing key hash AND Internal test certificate hash (if applicable)
See the Facebook documentation for more details.

ProGuard Issues

If you’re using ProGuard for code obfuscation in release builds, add the following to your proguard-rules.pro:
-keep class com.facebook.** { *; }
-keep interface com.facebook.** { *; }

Next Steps

Once Android setup is complete, you can:

Build docs developers (and LLMs) love