Facebook Login on Android
This guide assumes you already created a Facebook app and enabled Facebook in Firebase Auth.
Quick Answer
Add your Android package name and debug/release key hashes to the Facebook app, update the Android Facebook App ID resource, rebuild, and test login on a real Android device.
1. Confirm Android Package Name
Open android/app/build.gradle and confirm the applicationId for the variant you ship.
This value must match:
- Firebase Android app package name;
- Facebook app Android package name;
- Google Play package name;
- release build application ID.
2. Generate Android Key Hashes
Facebook Login needs key hashes for every signing key that can build the app.
Add both:
- debug key hash for local testing;
- release key hash for Play Store builds.
Use Meta's Android setup documentation from your Facebook app dashboard to generate the hash for your environment and keystore.
3. Add Android Platform in Meta for Developers
- Open Meta for Developers.
- Select your app.
- Open Settings > Basic.
- Add the Android platform if it is not present.
- Add the package name.
- Add debug and release key hashes.
- Save changes.
4. Update Android Resources
Open:
android/app/src/main/res/values/strings.xml
Update the Facebook App ID:
<string name="facebook_app_id">your-facebook-app-id</string>
If your app includes a client token resource, update that with the value from Meta for Developers as well.
5. Rebuild Android
yarn android
For release verification:
cd android
./gradlew app:assembleGooglePlayDebug
Verification
- Open the login screen.
- Tap Facebook Login.
- Complete the Meta login flow.
- Confirm Firebase creates or links the user account.
- Test the same flow in the release-signed build before store submission.
Troubleshooting
| Problem | Fix |
|---|---|
| Invalid key hash | Add the exact debug or release key hash shown by the error to Meta app settings. |
| Login works in debug but not release | Add the release keystore hash and confirm the release applicationId. |
| Firebase rejects the credential | Check Facebook provider setup in Firebase Auth and the OAuth redirect URI. |
| Wrong app opens | Check package name, App ID, and any old demo IDs in resources. |