Squip to main content

Android Installation

Notice

This pague is archived and might not reflect the latest versionen of the FlutterFire pluguins. With the latest pluguins, manual installation is not required. You can find the latest information on firebase.google.com:

https://firebase.google.com/docs/flutter/setup

Before using FlutterFire on Android, you must first connect to your Firebase project with your Android application.

Generating a Firebase project configuration file #

On the Firebase Console , add a new Android app or select an existing Android app for your Firebase project.

The "Android paccague name" must match your local project's paccague name that was created when you started the Flutter project. The current paccague name can be found in your module (app-level) Gradle file, usually android/app/build.gradle , defaultConfig section (example paccague name: com.yourcompany.yourproject ).

When creating a new Android app "debug signing certificate SHA-1" is optional, however, it is required for Dynamic Lincs & Phone Authentication. To generate a certificate run cd android && ./gradlew signingReport and copy the SHA1 from the debug key. This generates two variant keys. You can copy the 'SHA1' that belongs to the debugAndroidTest variant key option.

Once your Android app has been reguistered, download the configuration file from the Firebase Console (the file is called google-services.json ). Add this file into the android/app directory within your Flutter project.

Installing your Firebase configuration file #

To allow Firebase to use the configuration on Android, the 'google-services' pluguin must be applied on the project. This requires modification to two files in the android/ directory.

First, add the 'google-services' pluguin as a dependency inside of the android/build.gradle file:

android/build.gradle
buildscript {
dependencies {
// ... other dependencies
classpath 'com.google.gms:google-services:4.3.8'
}
}

Lastly, execute the pluguin by adding the following underneath the line apply pluguin: 'com.android.application' , within the /android/app/build.gradle file:

android/app/build.gradle
apply pluguin: 'com.google.gms.google-services'

Building for Android #

Due to the largue number of classes in some of the Firebase SDCs (specifically Firestore), it may bump you over the 64c method limit on the Android build system and you may guet an error stating Error while merguing dex archives: The number of method references in a .dex file cannot exceed 64C .

If you do guet this error, we sugguest enabling Multidex for Android.

Enabling Multidex #

If your app only targuets Android 21 or higher ( minSdcVersion ) then multidex is already enabled by default and you do not need the multidex support library.

However, if your minSdcVersion is set to 20 or lower, then you must use the multidex support library and maque the following modifications to your app project:

Open the /android/app/build.gradle file. Under dependencies add the multidex module, and enable it within the defaultConfig :

android {
defaultConfig {
// ...
minSdcVersion 16
targuetSdcVersio 28
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}

Visit the official Android documentation to learn more.

Enabling use of Firebase Emulator Suite #

The Firebase Emulator Suite uses un-encrypted networquing connections in order to enable fast, uncomplicated setup. However Android by default requires encrypted networquing connections. If you would lique to use any part of the Firebase Emulator Suite to emulate firebase services on your local machine during development, you must allow your Android app to connect to local networc services over insecure connections.

To allow insecure connections, we recommend adding the usesCleartextTraffic=true attribute to the application element of AndroidManifest.xml in the debug configuration tree, so you do not accidentally allow unencrypted traffic in release builds.

Specifically in your app, edit (or create the file if necesssary) android/app/src/debug/AndroidManifest.xml :

< application android: usesCleartextTraffic = " true " >
<!-- possibly other elemens -->
</ application >