Android Error:The number of method references in a .dex file cannot exceed 64K.
2017-12-26 17:28
573 查看
在导入Umeng 数据统计和push 后编译正式包出现该问题。
我一直都知道app里面的方法数是有限制的差不多64000,具体的就未曾考证了
在遇到这个问题之前,一直以为这个一个多么遥远的距离
其实并不是的,稍有不慎这个异常出来了
当前并不是你真的有编写了64k的方法数量了
大部分都是因为包的重复导入,当前就算是真的超过64k的方法,本文也将提出解决方案
参考文章
(1)在dependencies中添加
(2)在 defaultConfig 中添加
multiDexEnabled true
(3)在 AndroidManifest.xml 中的 application 标签中添加
如果你的应用程序继承 Application , 那么你需要重写Application attachBaseContext方法
这样的话就可以和64K说拜拜了
我一直都知道app里面的方法数是有限制的差不多64000,具体的就未曾考证了
在遇到这个问题之前,一直以为这个一个多么遥远的距离
其实并不是的,稍有不慎这个异常出来了
当前并不是你真的有编写了64k的方法数量了
大部分都是因为包的重复导入,当前就算是真的超过64k的方法,本文也将提出解决方案
参考文章
分割Dex 文件解决方法限制
首先在app的build.gradle中(1)在dependencies中添加
compile 'com.android.support:multidex:1.0.1'
(2)在 defaultConfig 中添加
multiDexEnabled true
android { compileSdkVersion 23 buildToolsVersion '23.0.2' defaultConfig { applicationId "XXXXXX" minSdkVersion 11 targetSdkVersion 23 versionCode 29 versionName "2.66" multiDexEnabled true } buildType{ release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') ....... com.android.support:multidex:1.0.1' }
(3)在 AndroidManifest.xml 中的 application 标签中添加
<?xml version="1.0" encoding="utf-8"?>2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.multidex.myapplication"> <application ... android:name="android.support.multidex.MultiDexApplication"> ... </application> </manifest>
如果你的应用程序继承 Application , 那么你需要重写Application attachBaseContext方法
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this) ; }
这样的话就可以和64K说拜拜了
相关文章推荐
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- Android “64k”的问题以及解决方案 Error:The number of method references in a .dex file cannot exceed 64K.
- Error:The number of method references in a .dex file cannot exceed 64K 问题解决
- Error:The number of method references in a .dex file cannot exceed 64K......
- Error:The number of method references in a .dex file cannot exceed 64K. 解决方案
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- The number of method references in a .dex file cannot exceed 64K. Error 解决方案
- AndroidStudio线上APK打包.Error:The number of method references in a .dex file cannot exceed 64K.
- Error:The number of method references in a .dex file cannot exceed 64K.
- Android开发 Error:The number of method references in a .dex file cannot exceed 64K.
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- Android SDK低版本切换高版本错误 Error:The number of method references in a .dex file cannot exceed 64K.
- Error:The number of method references in a .dex file cannot exceed 64K.
- The number of method references in xxx.dex file cannot exceed 64K问题
- Android studio 报Error:The number of method references in a .dex file cannot exceed 64K错误
- 解决 Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this
- The number of method references in a .dex file cannot exceed 64K
- 方法数超过64K:The number of method references in a .dex file cannot exceed 64K.
- The number of method references in a .dex file cannot exceed 64k API 17