Prerequisites
Before setting up the Android SDK:- Install the library via npm/yarn
- Follow the Facebook Android SDK Getting Started Guide to set up a Facebook app
- The library will be auto-linked on React Native 0.60+
Configuration
Add Facebook App ID to strings.xml
Open or create Replace:
android/app/src/main/res/values/strings.xml and add your Facebook credentials:YOUR_FACEBOOK_APP_IDwith your Facebook App IDYOUR_CLIENT_TOKENwith your Facebook Client Token (found in Facebook Developers > Settings > Advanced)
Generate and add Key Hash
Generate the key hash for your debug keystore:Default debug keystore password: For internal testing: Repeat the process for the SHA-1 from Release > Internal app sharing > Internal test certificate.
For macOS/Linux:
androidFor Windows:
For Release Builds:
Point the command to your app’s release keystore file. You can find its location by checking thestoreFile property in android/app/build.gradle:For Google Play App Signing:
- Go to Play Console
- Navigate to Release > App signing > App signing key certificate
- Copy the SHA-1 certificate fingerprint
- Convert it to Base64:
Add Key Hash to Facebook:
- Go to Facebook Developers
- Select your app
- Go to Settings > Basic
- Scroll down to Key Hashes
- Add the generated hash(es)
Manual Linking (React Native < 0.60)
Troubleshooting
Cannot run the Android project
Possible causes:- You didn’t add the required configuration to
strings.xmlandAndroidManifest.xml - You didn’t set up a Facebook app properly
- Your Facebook App ID or Client Token is incorrect
”Error logging you into this application” when using 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)
ProGuard Issues
If you’re using ProGuard for code obfuscation in release builds, add the following to yourproguard-rules.pro: