Hello Guys. Many times we Face Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio. So in this tutorial, we are going to solve this error.
How Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio Error occurs?
I am facing this error when I Use firestore with flutter app.
D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\Milan\AndroidStudioProjects\Milan_flutter_projects\bakery\bakery\build\app\intermediates\transforms\dexBuilder\debug\2.jar,
The number of method references in a .dex file cannot exceed 64K.
Learn how to reso
How to solve Flutter Firestore causing D8: Cannot fit requested classes in a single dex ?
- How to solve Flutter Firestore causing D8: Cannot fit requested classes in a single dex?
to solve Flutter Firestore causing D8: Cannot fit requested classes in a single dex By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn't really work with Jelly Bean out of the box. So we have to do 2 task to solve this error. Open android/app/build.gradle, then find the line that says minSdkVersion 16. Change that line to minSdkVersion 21. Save the file. and then Enable multidex now your error must be solved.
- Flutter Firestore causing D8: Cannot fit requested classes in a single dex
to solve Flutter Firestore causing D8: Cannot fit requested classes in a single dex By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn't really work with Jelly Bean out of the box. So we have to do 2 task to solve this error. Open android/app/build.gradle, then find the line that says minSdkVersion 16. Change that line to minSdkVersion 21. Save the file. and then Enable multidex now your error must be solved.
Solution 1: Change minimum target SDK
By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn’t really work with Jelly Bean out of the box.
So we have to do 2 task to solve this error.
- Change minimum target SDK
- Open
android/app/build.gradle
, then find the line that saysminSdkVersion 16
. - Change that line to
minSdkVersion 21
. - Save the file.
2. Enable multidex.
- Open and modify
project/app/build.gradle
file to enable multidex and add the multidex library as a dependency, as shown here :
android {
defaultConfig {
...
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Here is official Document Official guide.
Solution 2: Enable multidex.
Enable multidex.
Open project/app/build.gradle
and add the following lines.
defaultConfig {
...
multiDexEnabled true
}
then
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
If you have migrated to AndroidX, you’ll want this instead.
dependencies {
...
implementation 'androidx.multidex:multidex:2.0.1'
}
Now, Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio Error is solved. If you still facing this error so Comment below your error with code. I Will Help You. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.
Summery
So, It’s All About This Solution. I hope this tutorial helps you lot. Please Comment Below if You stucks anywhere with my code. Thank You.
Leave a Reply