Android 解决“com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536”问题
2015-09-18 19:53
429 查看
Google decided to release an official solution for this in the form of the MultiDex Support Library.
(谷歌给出的官方解决办法)
Then enable multi-dexing by setting the multiDexEnabled flag in the buildType or productFlavor section of your gradle configuration.
(设置multiDexEnabled 标签到gradle配置)
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
2、(如果你有自己的application,可以将继承Application改成去继承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:
(如果你编译的时候报oom,使用如下的方法)
Your compilation process might run out of memory. To fix it, set the following dex options in the ‘android’ closure
详细见:
http://stackoverflow.com/questions/27377080/after-update-of-as-to-1-0-getting-method-id-not-in-0-0xffff-65536-error-i
(谷歌给出的官方解决办法)
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" ...
2、(如果你有自己的application,可以将继承Application改成去继承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); } }
(如果你编译的时候报oom,使用如下的方法)
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
相关文章推荐
- 你是不是也被Android Private Libraries、Referenced Libraries、android Dependency搞晕了~~
- Android 自定义View实现SlideSwitchView
- android:windowSoftInputMode属性详解
- android init.rc文件语法详解
- Android CheckBox实现SwitchButton
- android自定义组件(手机加速球+水面波动效果)
- android多媒体——5步学会使用系统相机
- Android-sqlite3 not found解决
- Android EditText监听只能输入2位小数
- android开发(45) 自定义软键盘(输入法)
- android github 资源地址
- android studio下使用getclassloader().getresourceasstream()的问题
- 【Android】课程表布局实现(支持动态添加课程)
- android开发(44) 使用了 SoundPool 播放提示音
- Android 手机相册图片选择
- android 文件夹
- Android之实现妙趣横生的粘连布局
- android 滑动分页
- android ant 打包报错: [aapt] invalid resource directory name:
- Android四舍五入保留两位小数