为 Flutter 添加 multidex 支持
Adding multidex support to Flutter
我正在使用 Flutter 构建我的应用程序。现在我总是收到这个错误:
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: 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 32s Finished with error: Gradle build failed: 1
所以这个错误清楚地表明我必须添加 multidex-support。但是如何在 FLUTTER 中做到这一点?
最后,我通过删除 CloudFirestore 实现修复了它。好像当时版本有问题
问题不在于 Firebase 或 Firestore - 它是您添加到应用程序的依赖项的数量,您需要启用 Multidex - 有一些关于如何在线完成的步骤
Android5.0 之前的平台版本使用 Dalvik 运行时来执行应用程序代码。默认情况下,Dalvik 将应用程序限制为每个 APK 一个 classes.dex 字节码文件。为了绕过这个限制,您可以将 multidex 支持库添加到您的项目中:
dependencies {
def multidex_version = "2.0.1"
implementation 'androidx.multidex:multidex:$multidex_version'
}
要查看此库的当前版本,请参阅版本页面上有关 Multidex 的信息。
如果您不使用 AndroidX,请改为添加以下支持库依赖项:
dependencies {implementation 'com.android.support:multidex:1.0.3'}
我正在使用 Flutter 构建我的应用程序。现在我总是收到这个错误:
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: 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 32s Finished with error: Gradle build failed: 1
所以这个错误清楚地表明我必须添加 multidex-support。但是如何在 FLUTTER 中做到这一点?
最后,我通过删除 CloudFirestore 实现修复了它。好像当时版本有问题
问题不在于 Firebase 或 Firestore - 它是您添加到应用程序的依赖项的数量,您需要启用 Multidex - 有一些关于如何在线完成的步骤
Android5.0 之前的平台版本使用 Dalvik 运行时来执行应用程序代码。默认情况下,Dalvik 将应用程序限制为每个 APK 一个 classes.dex 字节码文件。为了绕过这个限制,您可以将 multidex 支持库添加到您的项目中:
dependencies { def multidex_version = "2.0.1" implementation 'androidx.multidex:multidex:$multidex_version' }
要查看此库的当前版本,请参阅版本页面上有关 Multidex 的信息。
如果您不使用 AndroidX,请改为添加以下支持库依赖项:
dependencies {implementation 'com.android.support:multidex:1.0.3'}