android 65535限制(android studio)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_23575795/article/details/78465282

方法数超过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);
}                                                                                                     

猜你喜欢

转载自blog.csdn.net/qq_23575795/article/details/78465282