解决Flutter项目无报错运行时assembleDebug报错(64K错误)

解决项目无报错运行时assembleDebug报错(64K错误)

原创:@As.Kai
博客地址:https://blog.csdn.net/qq_42362997
如果以下内容对您有帮助,点赞点赞点赞~

报错信息:

* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > 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

我们主要看这一句
The number of method references in a .dex file cannot exceed 64K.

这个报错信息大概讲的是:
一个.dev文件中方法引用的数量不能超过64k
我们的项目中应该是引用了较多的依赖包超过了官方规定的 64K大小
使得方法引用过多导致报错

在网上查找相关问题时发现:

The problem is with multidex builder. Actually, this often happens when you have imported a lot of packages in your yaml file which cannot fit into a single .dex built hence you have to enable multidex.

他的意思大概是说由于在pubspec.yaml文件中导入了过多无法放入单个.dex文件依赖包,所以你必须启用multidex进行分包

解决方案:

Go to android/app/build.gradle and add the following lines of codes:
意思是转到android / app / build.gradle并添加以下代码行:

dependencies {
  implementation 'com.android.support:multidex:1.0.3' //enter the latest version
}
android {
    defaultConfig {
        multiDexEnabled true
    }
}

最后重新运行程序,问题完美解决!

别忘了点赞~
关注我,一起成长!
@As.Kai

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

As.Kai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值