解决方法数越界
来源:互联网 发布:linux强制关闭程序 编辑:程序博客网 时间:2024/05/02 02:10
MultiDex
解决方法数越界
- 资料
- 配置
- 用法
- 自定义Dex
资料
Android 开发艺术探索 - 任玉刚
配置
- 在模组的gradle中配置
android { defaultConfig { // enable multidex support multiDexEnabled true }}
- Android 5.0 以下需要导包
dependencies { compile 'com.android.support:multidex:1.0.1'}
用法
- 在自定义Application中初始化,继续加载其他的 dex
- Application的成员变量和代码块初始化在
attachBaseContext
方法之前,故不能访问未在主dex中打包的类
@Overrideprotected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this);}
- 或者,直接使用
MultiDexApplication
- 或者,继承使用
MultiDexApplication
自定义Dex
- multidex的9个类必须打包到主dex,否则无法继续加载其他dex
- maindexlist.txt格式,通过脚本或手动生成
com/test/multidextest/TestApplication.classcom/test/multidextest/MainActivity.class// multidexandroid/support/multidex/MultiDex.classandroid/support/multidex/MultiDexApplication.classandroid/support/multidex/MultiDexExtractor.classandroid/support/multidex/MultiDexExtractor$1.classandroid/support/multidex/MultiDex$V4.classandroid/support/multidex/MultiDex$V14.classandroid/support/multidex/MultiDex$V19.classandroid/support/multidex/ZipUtil.classandroid/support/multidex/ZipUtil$CentralDirectory.class
- 自定义maindexlist.txt指定主dex中包含的类
afterEvaluate { println "afterEvaluate" tasks.matching { it.name.startsWith('dex') }.each { dx -> def listFile = project.rootDir.absolutePath + '/app/maindexlist.txt' println "root dir:" + project.rootDir.absolutePath println "dex task found: " + dx.name if (dx.additionalParameters == null) { dx.additionalParameters = [] } dx.additionalParameters += '--multi-dex' // 越界时产生分dex dx.additionalParameters += '--main-dex-list=' + listFile // 主dex中打包的类列表 dx.additionalParameters += '--minimal-main-dex' // 只有指定的类才打包到主dex }}
0 0
- Multidex解决方法数越界
- 解决方法数越界
- multidex解决方法数越界
- 使用Multidex解决方法数越界
- Android系统解决方法数越界
- Android使用multidex解决方法数越界问题65536
- 安卓使用 multidex解决方法数越界问题65536
- 解决Android应用方法数不能超过65K问题-使用multidex来解决方法数越界
- 利用DexClassLoader解决方法越界
- C++内存越界问题及解决方法
- C++内存越界问题及解决方法
- 浮点数越界或者无效-1.#IND000
- 浮点数越界或者无效-1.#IND000
- 有关组合数越界的问题
- 越界
- input文本框宽度设置100%时越界的解决方法
- 关于c语言三位八进制数越界的探讨
- Android 使用 Multidex 解决 65536 方法数越界问题
- PHP如何接入第三方短信SDK
- android NDK搭建与开发(一)
- Oracle数据库中文乱码问题解决
- c++ sort()与qsort()函数使用
- Android SurfaceView 多线程绘图
- 解决方法数越界
- Spring学习笔记之Spring MVC的高级技术
- 【莫队】莫队算法的扩展
- 兑换码编码方案实践
- 3.20
- 会话管理
- JQuery min.js .js 区别
- Linux中用stat命令查看文件时3个时间点解析
- 机器学习算法简单汇总