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:1.0.3' //enter the latest 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
}

You can follow the guidelines mentioned here

https://developer.android.com/studio/build/multidex

or to cut the story short and directly go to answer

Find android/app/build.gradle file and add the following lines of codes:

dependencies {
  compile 'com.android.support:multidex:1.0.3' 
  //find latest version from here https://developer.android.com/studio/build/multidex
}

android {
    defaultConfig {
        multiDexEnabled true
    }
}