Adding Required Packages

Learn how to add required Firebase packages inside our Flutter project.

We'll cover the following

First, we need to enable multidex in our project.

Configure multidex

Since some Firebase SDKs (particularly Firestore) include a significant number of classes, we may exceed the Android build system’s 64K method limit and receive an error while merging dex archives. (The maximum amount of method references in a .dex file is 64K.)

If we see this error, it is recommended that we enable multidex for Android.

If our app only targets Android 21 or higher (minSdkVersion), multidex is already enabled by default, and the multidex support library isn’t required.

If our minSdkVersion is 20 or lower, we’ll need to use the multidex support library and make the following changes to our app project:

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

Get hands-on with 1200+ tech skills courses.