很多时候,出于学习或者安全测试的目的,我们需要反编译andoridapp的安装文件来查看源码。一起来搭建Macos下的反编译环境吧。建立安装环境基础文件夹mkdir-p~/study/apkkiller/soft/bin编译apk文件需要下载apktool和dex2jar这两个软件,这两个软件都托管在googlecode上:http://code.google.com/p/android-apktool/http://code.google.com/p/dex2jar/从上面两个页面找到下载地址,这里我们找到apktool1.5.2和dex2jar-0.0的下载地址.9.15:cd~/study/apkkiller/soft/srcwgethttp://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2wgethttp://dex2jar.googlecode.com/files/dex2jar-0.0。9.15.zip解压后文件存放在以下目录:~/study/apkkiller/soft/src/apktool1.5.2~/study/apkkiller/soft/src/dex2jar-0.0.9.15为了方便,创建两个软链接:ln-s~/study/apkkiller/soft/src/apktool1.5.2/apktool.jar~/study/apkkiller/soft/bin/apktoolln-s~/study/apkkiller/soft/src/dex2jar-0.0.9.15/dex2jar.sh~/study/apkkiller/soft/bin/dex2jar测试反编译环境大家start反编译我们的测试apk文件看看环境能不能正常运行.apk./输出/测试/源/test.zipunzip./output/test/source/test.zip-d./output/test/source/testcp./output/test/source/test/classes.dex./output/test/source/classes.dex~/study/apkkiller/soft/bin/dex2jar./output/test/source/classes.dex#output./output/test/source/classes_dex2jar.jar查看反编译后的文件,可以下载jd-gui工具,打开上面生成的./output/test/source/classes_dex2jar.jar文件就够了。这个工具可以导出所有的源码包。从以下地址下载jd-gui:http://jd.benow.ca/http://jd.benow.ca/jd-gui/downloads/jd-gui-0.3.5.osx.i686的资源文件.dmgapk存放在我们上面解压的./output/test/source/test文件夹中,里面有很多xml文件,但是是加密的,不能直接查看。这时候需要用到apktool工具:java-jar~/study/apkkiller/soft/bin/apktoold./test.apk./output/test/source/test_resource合并导出的源码和资源文件,然后我们得到了我们想要的结果。
