0
点赞
收藏
分享

微信扫一扫

Android工程中方法数超过65536解决方法(Kotlin)

Star英 2022-02-27 阅读 86


Android Studio报错:

The number of method references in a .dex file cannot exceed 64K.

Caused by: com.android.tools.r8.utils.AbortException: Error: Cannot fit requested classes in a single dex file (# methods: 68815 > 65536)

解决方案


  1. build.gradle文件android的defaultConfig里面增加​​multiDexEnabled true​Android工程中方法数超过65536解决方法(Kotlin)_ide
  2. build.gradle文件dependencies里面增加​​implementation 'com.android.support:multidex:1.0.3'​Android工程中方法数超过65536解决方法(Kotlin)_ide_02
  3. Application类中增加

  • kotlin写法
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(this)
}
  • java写法
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

点击关注专栏,查看最新技术分享

更多技术总结好文,请关注:「程序园中猿」

Android工程中方法数超过65536解决方法(Kotlin)_android_03Android工程中方法数超过65536解决方法(Kotlin)_新技术_04



举报

相关推荐

0 条评论