方法数超过65535的限制?因为在Dalvik指令集里,调用方法的invoke-kind指令中,method reference index只给了16bits,最多能调用65535个方法,所以在生成dex文件的过程中,当方法数超过65535就会报错。控制台会看到DexException。
1.app.build中:
defaultConfig {
multiDexEnabled true
}
2.添加Library dependency:
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
3.创建自己的Application类 可以直接继承MultiDexAppliction 或者继承Application重写attachBaseContext(Context context)方法:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}