我正在使用flutter和flutterfire构建应用程序(这使我可以使用flutter和firebase)。对于flutterfire,我正在使用firebase_auth。我停止开发了几个星期,然后回到我的应用程序无法正常工作。我将问题缩小为firebase_auth无法正常工作。为了对此进行测试,我在Android Studios上创建了一个全新的firebase应用程序,并尝试将其连接到flutterfire。我做了所有必要的步骤来做到这一点,并决定首先测试cloud_firestore来看看它是否可行。它做了。我在pubspec.yaml文件中添加了firebase_auth的行后,我的应用甚至无法构建。我得到的错误如下。我也已经测试了flutter_fire的早期版本。
D8: Cannot fit requested classes in a single dex file. Try supplying a
main-dex list.
methods: 65968 > 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: /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/5.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/6.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/7.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/8.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/9.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/303.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/304.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/305.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/306.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/307.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/308.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/309.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/310.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/311.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/312.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/313.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/314.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/315.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/316.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/317.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/318.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/319.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/320.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/321.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/322.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/323.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/324.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/325.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/326.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/327.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/328.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/329.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/330.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/331.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/332.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/333.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/334.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/335.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/336.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/337.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/338.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/339.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/340.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/341.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/342.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/343.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/384.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/390.jar, /Users/nolan/Documents/development/lp_2/lp_2/build/app/intermediates/transforms/dexBuilder/debug/396.jar
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 2s
Finished with error: Gradle build failed: 1
答案 0 :(得分:3)
该问题看起来与Android相关,而不是iOS或Flutter。 如果将minSdkVersion设置为21或更高,则只需在模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
更多信息:https://developer.android.com/studio/build/multidex,尤其是如果minSdkVersion <21