Execution failed for task ':app:mergeDexDebug'. Firestore | Flutter

The problem is with multidex builder. Actually, this often happens when you have imported a lot of packages in your yaml file which cannot fit into a single .dex built hence you have to enable multidex.

Go to android/app/build.gradle and add the following lines of codes:

dependencies {
  implementation 'com.android.support:multidex:2.0.1' //enter the latest multidex version
}
android {
    defaultConfig {
        multiDexEnabled true
    }
}

Fixed the issue, but don't understand why. Why do I need to enable multiDex when I believe Firestore is using AndroidX?

Anyway, the fix. Add multiDexEnabled true to your app/build.gradle

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
}