cloud_firestoreを試そうとサンプルを実行していたところ、以下の問題にぶつかりました。
現象
cloud_firestoreプラグイン導入後、ビルドが通りませんでした。
環境
- Flutter/Android
- firebase_core: ^0.4.0
- cloud_firestore: ^0.12.5+2
エラーメッセージ
D8: Cannot fit requested classes in a single dex file (# methods: 74144 > 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: /省略/ 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 3s Finished with error: Gradle task assembleDebug failed with exit code 1
解決策
minSdkVersionを21にする
これから作るアプリということで、21未満は切りました。
(私の環境ではmultiDexEnabled true
の設定は不要でした)
もし21未満の対応も必要な場合、下記サイトが参考になると思います。