美文网首页我的笔记Android知识
Android工程方法数超过65535,解决办法

Android工程方法数超过65535,解决办法

作者: 姚瑶大坏蛋 | 来源:发表于2016-06-28 17:03 被阅读7615次

Android工程方法数超过65535,解决办法

当方法数大于66535时,报错:

Error:Execution failed for task ':ttt:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

解决办法:谷歌官方推荐使用MultiDexApplication,具体步骤如下

Gradle 配置:

defaultConfig {   
       applicationId "XXX"
       minSdkVersion 14
       targetSdkVersion 23
       multiDexEnabled true
}
dependencies {
    compile 'com.android.support:multidex:1.0.0'
}

Application 类重写方法:

@Override
protected void attachBaseContext(Context base) {
   super.attachBaseContext(base);
   MultiDex.install(this);
}

相关文章

网友评论

本文标题:Android工程方法数超过65535,解决办法

本文链接:https://www.haomeiwen.com/subject/wlptjttx.html