skip to Main Content

When try to run the flutter dart program on physical device mobile at that time below error will show sometimes in Android Studio terminal :

Note: C:UsersAdministratorAppDataLocalPubCachehostedpub.devcloud_firestore-4.14.0androidsrcmainjavaioflutterpluginsfirebasefirestoreFlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:D8: Cannot fit requested classes in a single dex file (# methods: 112826 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:mergeExtDexDebug’.

A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
There was a failure while executing work items
A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

  • Try:

Run with –stacktrace option to get the stack trace.
Run with –info or –debug option to get more log output.
Run with –scan to get full insights.

BUILD FAILED in 4m 1s
[!] App requires Multidex support
Multidex support is required for your android app to build since the number of methods has exceeded 64k. See https://docs.flutter.dev/deployment/android#enabling-multidex-support for more information. You may pass the –no-multidex flag to skip Flutter’s multidex support to use a manual solution.

Flutter tool can add multidex support. The following file will be added by flutter:

android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java

cannot prompt without a terminal ui
Error: Gradle task assembleDebug failed with exit code 1

When the above Error show in the Android Studio Terminal at that time we should set minSdkVersion 21.
There are two build.gradle files in Android Studio.

1st build.gradle file : 1st build.gradle file is located at android folder -> build.gradle.

2nd build.gradle file : 2nd build.gradle file is located at android folder -> app folder -> build.gradle.

We have to select 2nd option from above shown options.
In the app level build.gradle file, we have to set android { defaultConfig { minSdkVersion 21 } }.
we have to set minSdkVersion 21 as shown above.

After doing this, above Android Studio console problem will be solved.

3

Answers


  1. Chosen as BEST ANSWER

    When the above Error show in the Android Studio Terminal at that time we should set minSdkVersion 21. There are two build.gradle files in Android Studio.

    1st build.gradle file : 1st build.gradle file is located at android folder -> build.gradle.

    2nd build.gradle file : 2nd build.gradle file is located at android folder -> app folder -> build.gradle.

    We have to select 2nd option from above shown options. In the app level build.gradle file, we have to set android { defaultConfig { minSdkVersion 21 } }. we have to set minSdkVersion 21 as shown above.

    After doing this, above Android Studio console problem will be solved.


  2. Simply put you should enable multidex in your app level build.gradle

    android {
    defaultConfig {
        ...
        minSdk = 15 
        targetSdk = 33
        multiDexEnabled = true
    }
    ...
    

    }

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

    Login or Signup to reply.
  3. android {

    defaultConfig
    {
    minSdkVersion 21
    }

    }

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search