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);
}
网友评论