下面是使用android studio(?!没错,android studio不光用来玩android,Itellij idea收费)编译调试apktool的图文教程:
0.参照上个教程配置好git/tortoise git等环境http://www.0xaa55.com/thread-1656-1-1.html,配置好jdk / android studio等软件
1.将apktool从github上下下来(参照上一篇帖子:如何编译gradle工程)
源码位于在:
如图,勾选recursive,开始下载源码(这一步可能需要翻墙什么的,我用的vpn,如果翻墙的话可以自己设置tortoisegit的代理服务器,在settings菜单中),最终得到80+M的apktool文件夹
2.经研究会发现check下来的master,最新源码并不适合编译,build.gradle中可以发现他们正在做2.0.3(),而master代码暂时还无法编译,所以我们需要check到2.0.2
Administrator@WINWORK-UC7OSF4 MINGW64 /e/androidsrc/apktool - 副本/Apktool/Apkto
ol (master)
$ git checkout 2.0.2
warning: unable to rmdir smali: Directory not empty
Note: checking out '2.0.2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at ee9d44c... version bump (2.0.2)
Administrator@WINWORK-UC7OSF4 MINGW64 /e/androidsrc/apktool - 副本/Apktool/Apkto
ol ((2.0.2))
$ git checkout -b 2.0.2
Switched to a new branch '2.0.2'
Administrator@WINWORK-UC7OSF4 MINGW64 /e/androidsrc/apktool - 副本/Apktool/Apkto
ol (2.0.2)
$
Administrator@WINWORK-UC7OSF4 MINGW64 /e/androidsrc/apktool - 副本/Apktool/Apkto
ol (2.0.2)
$ git fetch
最终得到源码
3.导入到android studio中,注意根目录要选择有build.gradle文件的那个,选择默认gradle wrapper(如果翻墙的话需要在android studio设置里配好代理)
之后经过一系列插件下载,编译之类的进去以后,会提示一堆(android framework和unregistered vcs root),看情况选即可,吧需要的插件装好:
11:32:08 Gradle sync started
11:32:11 Gradle sync completed
11:32:12 Frameworks detected: Android framework is detected in the project Configure
11:32:12 Unregistered VCS roots detected
The following directories are roots of VCS repositories, but they are not registered in the Settings:
E:\androidsrc\apktool - 副本\Apktool\Apktool\smali
E:\androidsrc\apktool - 副本\Apktool\Apktool
Add roots Configure Ignore
从菜单->view->Tool Windows->gradle打开gradle projects子视图,点下里面的refresh按钮
下方状态栏会频繁下载gradle指定的插件什么的
完事后是这样
5.配置调试,如图,选择edit configuration,加入jar application,命名为debug,path to jar 填写生成jar文件路径,参数根据需要填写一下即可
apply就可以看到debug条目了,在入口点apktool\brut.apktool\apktool-cli\src\main\java\brut\apktool\main.java设置断点,选择右边虫子按钮,开启调试!!!