Generate SHA-1 and SHA-256 keys

11. To generate SHA-1 and SHA-256 keys for your Flutter app and add them to your Firebase project, you can follow these steps:

(This important for Phone Auth, Google Sign-In )

11.1. Using Keytool:

11.1.1. Navigate to your JDK’s bin directory in the command line.

11.1.2. Execute the following command to generate the SHA-1 key:

11.1.3. Replace path-to-your-keystore-file with the path to your keystore file (usually debug.keystore for debug builds and a custom keystore for release builds) and your-alias-name with the alias name used to generate the keystore.

11.1.4. Similarly, execute the following command to generate the SHA-256
key:

11.2. Using Gradle (Android Studio):

11.2.1. Open your Flutter project in Android Studio.

11.2.2. In the Android view, navigate to app -> Gradle Scripts -> build.gradle (Module: app).

11.2.3. Add the following lines to the android block

11.2.4. Replace path-to-debug.keystore, password, and key-alias with your keystore file path, password, and key alias respectively.

11.2.5. Sync your project to apply changes.

11.2.6. Run the following Gradle task in the terminal to get the SHA-1 and SHA-256 keys

11.3. Adding Keys to Firebase Console:

11.3.1. Go to the Firebase Console.

11.3.2. Select your project.

11.3.3. For Android:

  • 11.3.3.1. Click on the Android icon to add an Android app.
  • 11.3.3.2. Follow the setup instructions, including adding the google-services.json file to your Flutter project’s android/app directory.
  • 11.3.3.3. During setup, you’ll be asked for your SHA-1 key. Paste the SHA-1 key you generated earlier.
  • 11.3.3.4. After setup is complete, you’ll have the option to download the google-services.json file again. Replace the existing file in your project if needed.

11.3.4. For IOS:

  • 11.3.4.1. Click on the iOS icon to add an iOS app.
  • 11.3.4.2. Follow the setup instructions, including downloading the GoogleService-Info.plist file.
  • 11.3.4.3. There’s no need to add SHA-1 or SHA-256 keys for iOS.
  • 11.3.4.4. Add the downloaded GoogleService-Info.plist file to your Flutter project’s ios/Runner directory.