問題現象:
問題原因:
Android系統中,一個Dex文件中存儲方法id用的是short類型數據,所以導致你的dex中方法不能超過65536
解決方法:Google 官方給出的解決方案是使用 Multidex 。
解決步驟:
1、修改 build.gradle 文件
defaultConfig {
...
multiDexEnabled true//設置爲true
}
2、添加支持庫
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
3、修改項目中的Application類,繼承MultiDexApplication
或者重寫attachBaseContext方法
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
問題解決