On this page14 sections
- Prerequisites
- Learning Objectives
- 1. Create the Firebase Project
- 2. Find the Package Name
- 3. Get the SHA Fingerprints
- 4. Register the Android App
- 5. Enable Sign-In Providers (if your app needs them)
- Code Examples
- Common Beginner Mistakes
- Best Practices
- Practice Questions
- Practice Answers
- Key Takeaways
- Full Code (Copy-Paste Reference)
Lecture 001: Firebase Project & Android App (SHA-1 / SHA-256)
| Category | 1: Firebase Setup |
| Lecture | 001 of 014 |
| Estimated video length | 16 min |
| Target | Flutter 3.44 · Dart 3.12 · FlutterFire (latest) |
| Level | Intermediate |
Everything in this course lives inside one Firebase project. We create it, register our Android app in it with its SHA fingerprints, and switch on the sign-in methods we may need.
Contents
Prerequisites · Objectives · Lesson · Code Examples · Common Mistakes · Best Practices · Practice Questions · Answers · Takeaways · Full Code
Prerequisites
A Flutter project that runs on Android. A Google account.
Learning Objectives
- Create a Firebase project
- Find your app's Android package name
- Get the SHA-1 and SHA-256 fingerprints with
keytoolorsigningReport - Register the Android app and download
google-services.json - Enable Authentication sign-in providers
1. Create the Firebase Project
- Open console.firebase.google.com → Create a project.
- Give it a name (for example
notify-demo). Firebase makes a unique project ID from it (notify-demo-a1b2c): you'll see it in the code later. - Keep Google Analytics switched on: Lecture 011 uses it. Pick or create an Analytics account.
- Create project.
2. Find the Package Name
Firebase identifies an Android app by its package name (application ID). It is in
android/app/build.gradle.kts:
android {
namespace = "com.example.notify_demo"
defaultConfig {
applicationId = "com.example.notify_demo"
// ...
}
}Choose your real package name now: it can't be changed in Firebase later. Something like
com.yourcompany.appname.
3. Get the SHA Fingerprints
A SHA fingerprint is a short code that identifies the key your app is signed with. Firebase needs it for Google Sign-In, phone authentication and App Check. Add both SHA-1 and SHA-256.
Option A: Gradle (shows every signing key, debug and release):
cd android
./gradlew signingReport # macOS / Linux
gradlew signingReport # WindowsOption B: keytool (the debug key only):
# macOS / Linux
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
# Windows
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass androidLook for these lines in the output:
SHA1: 5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25
SHA-256: FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C(Yours will be different.) The debug key is on every developer's computer; your release key (and Google Play's app-signing key, from Play Console → Test and release → App integrity) need adding too before you publish.
4. Register the Android App
- In the project overview, click the Android icon.
- Enter the package name, an optional nickname, and the SHA-1.
- Register app → Download google-services.json.
- Put the file in
android/app/(next tobuild.gradle.kts, not inandroid/). - Skip the remaining console steps: Lecture 002 does them the Flutter way.
Add the SHA-256 afterwards: Project settings → Your apps → Android app → Add fingerprint.
5. Enable Sign-In Providers (if your app needs them)
Build → Authentication → Get started → Sign-in method, then enable only what the app uses:
| Provider | Extra setup |
|---|---|
| Anonymous | none |
| Email/Password | none |
| needs the SHA-1 from step 3 | |
| Phone | needs SHA-1 and SHA-256; add test phone numbers with fixed codes for development |
Test phone numbers (Phone → Phone numbers for testing) let you sign in without receiving a real SMS: handy in an emulator and free.
Code Examples
Example 1: Where the Files Go
notify_demo/
├── android/
│ └── app/
│ ├── build.gradle.kts
│ └── google-services.json ← downloaded in step 4
├── ios/
│ └── Runner/
│ └── GoogleService-Info.plist ← Lecture 003
└── lib/
└── main.dartCommon Beginner Mistakes
1. google-services.json in the wrong folder: it must be in android/app/. In android/
the build fails with "File google-services.json is missing".
2. Package name mismatch: the name in Firebase must equal applicationId exactly, or the
build fails with "No matching client found for package name".
3. Only the debug SHA: Google Sign-In works while testing, then fails in the Play Store build. Add the release and Play app-signing fingerprints too.
Best Practices
- Use one Firebase project per app; make a separate project for testing if you need clean production data.
- Enable only the sign-in providers the app actually uses.
google-services.jsonidentifies your project, it doesn't grant access: but keep it out of public repositories anyway.
Practice Questions
- Where do you find an Android app's package name?
- Which command prints all signing fingerprints for a Flutter Android project?
- Where does
google-services.jsongo? - Why add test phone numbers?
Practice Answers
applicationIdinandroid/app/build.gradle.kts../gradlew signingReport, run insideandroid/.android/app/.- To sign in with phone auth during development without real SMS messages.
Key Takeaways
- One Firebase project holds every app and service.
- Register the Android app with its exact package name and SHA fingerprints.
google-services.jsongoes inandroid/app/.- Enable sign-in providers only as needed; use test numbers for phone auth.
Full Code (Copy-Paste Reference)
No Dart code yet: this lecture is console and file-placement work only. The one thing to copy is the file layout from Section 4:
notify_demo/
├── android/
│ └── app/
│ ├── build.gradle.kts
│ └── google-services.json ← downloaded in this lecture
├── ios/
│ └── Runner/
│ └── GoogleService-Info.plist ← Lecture 003
└── lib/
└── main.dart ← Firebase.initializeApp() arrives in Lecture 004