如何调试 Android 打包流程?

前言

其实和调试 gradle plugin 一个套路。

步骤

1、新建一个 Module,命名 buildSrc(buildsrc)

2、将 build.gralde 里的内容修改为:

1
2
3
4
5
6
7
8
9
10
11
12
apply plugin: 'groovy'
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:2.3.3' // 或者其他你需要调试的 android-plugin 的版本
}
repositories {
jcenter()
}

3、删除 Module 文件下除了 build.gradle 外的所有文件,然后 sync

4、点击 Edit configurations

5、新建 Remote

按照默认配置点击 OK

6、输入打包命令,末尾加上 -Dorg.gradle.debug=true --no-daemon

如:./gradlew assDebug -Dorg.gradle.debug=true --no-daemon

7、点击 debug

演示

按照以后步骤做后就可以愉快的调试了,来试验下。

打开 TaskManager.java,在判断是否需要使用 MultiDex 的地方打个断点。

然后执行步骤中的 6、7,然后等到这里被执行时就会断住了。

尾语

可能还有更好的方案。