The dreaded error message. It’s something we’ve all seen at some point or another when working with Flutter and Firebase. But what does it mean, exactly? And how do we fix it?
The Problem
It turns out that the problem lies with the multidex builder. Yep, you read that right. When we have a lot of packages imported in our yaml file that can’t fit into a single .dex built, we need to enable multidex.
Solving the Issue
To solve this issue, we simply need to add the following lines of code to our android/app/build.gradle file:
dependencies { implementation 'com.android.support:multidex:2.0.1' //enter the latest multidex version } android { defaultConfig { multiDexEnabled true } }
This should fix the issue, but we’re not entirely sure why we need to enable multidex in the first place. I mean, Firestore uses AndroidX, right? So why do we need to go back to using com.android.support?
The Fix (Again)
Despite not fully understanding the reasoning behind enabling multidex, the fix is simple enough. Just add the following line to your app/build.gradle file:
defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.poll" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //This line here... multiDexEnabled true }