Google decided to release an official solution for this in the form of the MultiDex Support Library.
(谷歌给出的官方解决办法)
dependencies {
...
compile 'com.android.support:multidex:'
...
}
Then enable multi-dexing by setting the multiDexEnabled flag in the buildType or productFlavor section of your gradle configuration.
(设置multiDexEnabled 标签到gradle配置)
defaultConfig {
...
multiDexEnabled true
...
}
Then depending on your project, you have 3 options:
(根据你的工程会有3中情况)
1、(如果你没有自己的Application)
If you haven’t created your own Application class, simply declare android.support.multidex.MultiDexApplication as your application class in AndroidManifest.xml
....
android:name="android.support.multidex.MultiDexApplication"
...
If you already have your own Application class, make it extend android.support.multidex.MultiDexApplication instead of android.app.Application
3、(如果你继承了其他的类,不用改变他,直接覆盖他的attachBaseContext()方法,如下:)
If your Application class is extending some other class and you don’t want to or can’t change it, override attachBaseContext() as shown below:
public class MyApplication extends FooApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Your compilation process might run out of memory. To fix it, set the following dex options in the ‘android’ closure
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
详细见:
http://stackoverflow.com/questions/27377080/after-update-of-as-to-1-0-getting-method-id-not-in-0-0xffff-65536-error-i