Solvedflutter Issue with cloud_firestore - Cannot fit requested classes in a single dex file.
✔️Accepted Answer
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps with over 64K methods.
In short
Add multidex library to android app depedency (/android/app/build.gradle)
...
android {
...
defaultConfig {
...
multiDexEnabled true
}
...
}
...
dependencies {
implementation 'com.android.support:multidex:1.0.3' // use latest version
...
}
...
Other Answers:
Thanks - I actually found that just setting the minSdkVersion to 21 without any other changes did the trick for me. Maybe the Firebase/Firestore team could recommend that as a suggestion or at least mention the other bits about multidex if 21 is to high ..
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps with over 64K methods.
In short
Add multidex library to android app depedency (/android/app/build.gradle)
... android { ... defaultConfig { ... multiDexEnabled true } ... } ... dependencies { implementation 'com.android.support:multidex:1.0.3' // use latest version ... } ...
Awesome. It seems to have done the trick. Thanks a load
I solved it by just changing
android/app/build.gradle
defaultConfig {
minSdkVersion 16
to
minSdkVersion 28
}
Had the same issue when trying to add cloud_firestore: ^0.12.9+4
followed @FlashJonas approach and changed:
minSdkVersion 16
to
minSdkVersion 21
worked perfectly.
UPDATE:
today while doing unrelated research on my flutter project, I came across a codelab where they actually advise you to use this approach(see screenshot).
link(step 4): https://codelabs.developers.google.com/codelabs/flutter-firebase/index.html#3
Enabling multidex and adding the multidex support library works on Android 5.0 and higher, but will immediately crash the application on devices with Android prior to Android 5.0.
Steps to Reproduce
I've just started learning flutter and I reached to this codelab:
https://codelabs.developers.google.com/codelabs/flutter-firebase/index.html?index=..%2F..%2Findex#8
Basically I'm trying flutter with firebase, so you can follow the same codelab to reproduce.
Logs
Output when running the app
flutter run --verbose
flutter analyze
flutter doctor -v