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

后端 未结 6 1845
[愿得一人]
[愿得一人] 2021-01-31 08:32

Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error: Execution failed for tas

相关标签:
6条回答
  • 2021-01-31 09:05

    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
        }
    }
    
    0 讨论(0)
  • 2021-01-31 09:09

    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
        }
    }
    
    0 讨论(0)
  • 2021-01-31 09:20

    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
    }
    
    0 讨论(0)
  • 2021-01-31 09:26

    When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture: https://developer.android.com/studio/build/multidex

    add multiDexEnabled true in app/build.gradle defaultConfig at last.

    defaultConfig{ ... multiDexEnabled true }

    0 讨论(0)
  • 2021-01-31 09:28

    I just met with this error, and it turns out it can be fixed easily. Of course, other answers on this are really great and it tells you how to fix it. However, I was wondering why this even happened. It turns out this comes from the minSdkVersion used. If this is set to 20 or lower, you need to configure your app for multiDex support.

       defaultConfig {
            applicationId "com.inspire.aaym"
            minSdkVersion 21
            targetSdkVersion 30
        }
    

    So, if you app is not intended to be used in Android version prior to 5.0, setting the minSdkVersion number to 21 will easily fix this issue. If not, follow the workaround to enable mutiDex support.

    Read more from the official document: https://developer.android.com/studio/build/multidex#mdex-gradle

    0 讨论(0)
  • 2021-01-31 09:28

    If you are using AndroidX,

    Add below lines to app/build.gradle

    multiDexEnabled true // to the defaultConfig {}

    implementation 'androidx.multidex:multidex:2.0.1' // to the dependencies

    To the AndroidManifest.xml (Optional)

    <application
        android:name="androidx.multidex.MultiDexApplication"
    

    Please note that you have to extends MainActivity to the MultiDexApplication. If you change android:name.

    0 讨论(0)
提交回复
热议问题