On this page14 sections
  1. Prerequisites
  2. Learning Objectives
  3. 1. Create the Firebase Project
  4. 2. Find the Package Name
  5. 3. Get the SHA Fingerprints
  6. 4. Register the Android App
  7. 5. Enable Sign-In Providers (if your app needs them)
  8. Code Examples
  9. Common Beginner Mistakes
  10. Best Practices
  11. Practice Questions
  12. Practice Answers
  13. Key Takeaways
  14. Full Code (Copy-Paste Reference)

Lecture 001: Firebase Project & Android App (SHA-1 / SHA-256)

Category1: Firebase Setup
Lecture001 of 014
Estimated video length16 min
TargetFlutter 3.44 · Dart 3.12 · FlutterFire (latest)
LevelIntermediate

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 keytool or signingReport
  • Register the Android app and download google-services.json
  • Enable Authentication sign-in providers

1. Create the Firebase Project

  1. Open console.firebase.google.com → Create a project.
  2. 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.
  3. Keep Google Analytics switched on: Lecture 011 uses it. Pick or create an Analytics account.
  4. 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:

kotlin
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):

bash
cd android
./gradlew signingReport        # macOS / Linux
gradlew signingReport          # Windows

Option B: keytool (the debug key only):

bash
# 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 android

Look for these lines in the output:

code
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

  1. In the project overview, click the Android icon.
  2. Enter the package name, an optional nickname, and the SHA-1.
  3. Register app → Download google-services.json.
  4. Put the file in android/app/ (next to build.gradle.kts, not in android/).
  5. 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:

ProviderExtra setup
Anonymousnone
Email/Passwordnone
Googleneeds the SHA-1 from step 3
Phoneneeds 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

code
notify_demo/
├── android/
│   └── app/
│       ├── build.gradle.kts
│       └── google-services.json      ← downloaded in step 4
├── ios/
│   └── Runner/
│       └── GoogleService-Info.plist  ← Lecture 003
└── lib/
    └── main.dart

Common 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.json identifies your project, it doesn't grant access: but keep it out of public repositories anyway.

Practice Questions

  1. Where do you find an Android app's package name?
  2. Which command prints all signing fingerprints for a Flutter Android project?
  3. Where does google-services.json go?
  4. Why add test phone numbers?

Practice Answers

  1. applicationId in android/app/build.gradle.kts.
  2. ./gradlew signingReport, run inside android/.
  3. android/app/.
  4. 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.json goes in android/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:

code
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