File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ afterEvaluate {
9898###坑6:主dex依然爆表,shit again!
9999其实上面那段脚本已经成功筛选出我们想要放入主Dex的` manifest_keep列表 ` 和` maindexlist列表 ` ,但是在打包的时候还是把所有类打进主Dex(已无语)。这个时候就需要跟[ DexKnifePlugin] ( https://github.com/ceabie/DexKnifePlugin ) 插件配合使用,首先在gradle中加上上述脚本,然后使用插件时在配置文件中加上 ` -split **.** ` 和` #-donot-use-suggest ` 。DexKnifePlugin插件运行原理很简单,在生成Dex任务之前首先读取自己的配置文件(包含前面我们通过Gradle脚本生成的` maindexlist ` 列表),然后扫描combined.jar(包含工程中所有.class文件)匹配出我们自定义的maindexlist.txt,再替换掉build/multi-dex/maindexlist.txt,和build实例。这样分包的时候就会基于我们的规则生成主Dex。
100100
101+ ###坑7:ANR,HAHAHA!
102+ 我们最低API=16,测试并未发现ANR问题,所以暂时没考虑景上添花,这个问题比较好解决。
103+ 参考=>[ Android Dex分包之旅] ( http://yydcdut.com/2016/03/20/split-dex/index.html )
104+
101105###Congratulation
102106恭喜,填坑终于结束,不过还有点不爽的是需要同时维护Gradle脚本和插件的配置。
103107于是乎就将Gradle脚本整合进了插件,这样只需维护一个配置文件就行了。读者可以根据自己需求自行选择分开配置还是整合配置。通过这种方式我们把主Dex的方法数维持在15000左右,从此再也不用担心方法数问题了!!!
@@ -176,4 +180,4 @@ Unsupported major.minor version 52.0
176180Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
177181> DexKnife Warnning: Main dex is EMPTY ! Check your config and project!
178182```
179- gradle 切到 1.5.0
183+ gradle 切到 1.5.0,目前就发现gradle 2.1.2有这问题。
You can’t perform that action at this time.
0 commit comments