Flutter Android: Failed to load FirebaseOptions from resource
PlatformException(java.lang.Exception, Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly., null, null)Short answer
On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json. If the plugin is not applied, the JSON file is missing or has the wrong package name, that file is never made. Fix the Gradle setup, or pass options from firebase_options.dart.
Fix it fast
1Find out which cause you have
Build the debug app, then look for the generated values.xml. If it is missing, the plugin did not run, which is the first cause.
flutter build apk --debug ls android/app/build/generated/res/google-services/debug/values/2Match what you see, then jump to its fix
- 1
No values.xml under build/generated/res/google-servicesThe Google services Gradle plugin is not appliedFix - 2
File google-services.json is missing, or the build runs but no values.xml is generated for a flavor or build typegoogle-services.json is missing or in the wrong folderFix - 3
The plugin finds no client entry with your package name, so it throws an exception, or resources such as gcm_defaultSenderId are missingThe package name in the JSON does not match the appFix - 4
The error appears at startup while google-services setup is correct, or you use FlutterFire configurationFirebase.initializeApp is called without optionsFix
- 1
What does the error look like?
PlatformException(java.lang.Exception, Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly., null, null)Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
Cause 1 of 4
The Google services Gradle plugin is not applied
1Check
The plugin turns google-services.json into values.xml. Search both Gradle files for its id.
grep -rn "com.google.gms.google-services" android/2Fix
Declare the plugin with its version and apply false in the project-level file, then apply it without a version in android/app. Use the version shown on the Firebase setup page.
// project-level plugins block (version as in the Firebase docs)
id("com.google.gms.google-services") version "4.6.0" apply false
// android/app/build.gradle.kts
plugins {
id("com.android.application")
id("com.google.gms.google-services")
}3Verify
Rebuild and check that values.xml now exists.
flutter clean
flutter build apk --debug
ls android/app/build/generated/res/google-services/debug/values/Confirmed by firebase.google.com
Cause 2 of 4
google-services.json is missing or in the wrong folder
1Check
The default place is app/google-services.json. A build type or flavor can have its own copy under app/src.
find android/app -name google-services.json2Fix
Download the file again from the Firebase console and put it in android/app, or in android/app/src/{build_type} when that build type uses a separate Firebase project.
cp ~/Downloads/google-services.json android/app/google-services.json3Verify
Run the build again.
flutter build apk --debugConfirmed by firebase.google.com
Cause 3 of 4
The package name in the JSON does not match the app
1Check
The plugin only uses the client entry whose package name matches your app. Compare the two values.
grep -n "applicationId" android/app/build.gradle*
grep -n "package_name" android/app/google-services.json2Fix
Register the exact application id in the Firebase console and download a fresh google-services.json.
# Firebase console > Project settings > Your apps > add Android app with the applicationId, then download the file3Verify
Rebuild after replacing the file.
flutter clean && flutter build apk --debugConfirmed by firebase.google.com
Cause 4 of 4
Firebase.initializeApp is called without options
1Check
flutterfire configure writes lib/firebase_options.dart. Check that main.dart passes it.
ls lib/firebase_options.dart
grep -n "initializeApp" -A 3 lib/main.dart2Fix
Run flutterfire configure and pass DefaultFirebaseOptions.currentPlatform to initializeApp.
flutterfire configure
// lib/main.dart
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);3Verify
Run the app on Android and watch for the exception.
flutter runConfirmed by firebase.google.com
How do I stop it coming back?
- Commit google-services.json and firebase_options.dart together so they always match.
- Re-run flutterfire configure whenever you add a platform, flavor or Firebase product.
- After changing the applicationId, register the new id in Firebase and download the JSON again.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
Flutter build fails: File google-services.json is missing
google-services.json is missing
The Google services Gradle plugin looks for google-services.json in the Android app module root.
3 causes, each with a fixMobile apps
Flutter: Firebase.initializeApp fails with Unable to establish connection on channel
Unable to establish connection on channel
The Dart side of firebase_core could not reach its native half.
4 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Flutter Android build fails: Java is too new for this Gradle version
Unsupported class file major version 61
Gradle only runs on Java versions it knows.
3 causes, each with a fix