I was trying to make a chat app using flutter and firebase, but then this error happens.
Here are all of the errors
> 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 41s
[!] 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
Exception: Gradle task assembleDebug failed with exit code 1
2
Answers
You need to enable MultiDex as mentioned in your errorcode. You can do it in your "build.gradle". Usually this failure code appears if your files are getting larger or you use a lot of assets.
Guide on how to do it.
In your stack trace you can see additional Infos on how to enable it.
In most cases, enough will do the first step
How to enable multidex for flutter project.
Enable multidex.
Open
[project_folder]/app/build.gradle
and add following lines.and
Enable Jetifier.
Open
[project_folder]/android/gradle.properties
and add following lines.android.useAndroidX=true
android.enableJetifier=true