Including multiple firebase_ plugins simultaneously in a pubspec.yaml file is enough to exceed the amount of Java methods that can be included in an Android APK by default, so compilation breaks.
flutter create foopubspec.yaml to add the extra deps below.dependencies:
cloud_firestore: any
firebase_core: any
firebase_database: any
firebase_ml_vision: any
firebase_performance: any
firebase_remote_config: any
firebase_storage: any
flutter build apkflutter build apk
Initializing gradle... 0.7s
Resolving dependencies... 1.4s
D8: Cannot fit requested classes in a single dex file (# methods: 76505 > 65536)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease'.
This can be addressed in affected apps using the plugins by turning on multidexing in their build following the same steps as a typical Android app.
It's not clear to me what should be done about this. It ties into wider ongoing discussions about abstracting underlying platform code.
flutter tool and print out a log pointing users to something explaining this error, what multidexing is, how to turn it on./cc @Sun3
/cc @dnfield @Hixie @amirh
@mklim
The issue at https://github.com/flutter/flutter/issues/27702 has been closed and moved here. Future collaboration on this issue will be done here.
Hi @mklim
You might want to check this possible solution
If are you still experiencing this issue
with the latest version of Flutter and FlutterFire plugin
can you please provide your flutter doctor -v
and your and your flutter run --verbose/flutter build --verbose ?
Also, to better address the issue, would be helpful
if you could post a self contained app on github
or the steps to reproduce it.
Thank you
I too had the same problem I just changed my min SDK version above 21 in the build.gradle, It solved the problem for me
For now, changing min SDK to 21 means losing ~5-6% old devices. Do you plan to make firebase sdk to work with SDK 16?
Found this useful document https://developer.android.com/studio/build/multidex
Most helpful comment
I too had the same problem I just changed my min SDK version above 21 in the build.gradle, It solved the problem for me