APK文件本身是一个压缩包,直接用解压工具即可打开,但里面的文件都已被编码为二进制文件格式,不能直接看,比如程序描述文件AndroidManifest.xml。
使用apktool工具可以将这些文件解码还原出来。apktool(http://code.google.com/p/android-apktool/ 现在地址是: http://ibotpeaches.github.io/Apktool/ )是一个非常著名的开源工具包,功能很强大,可以解包APK文件并重新打包,常用来汉化Android应用。
安装方法,参看 http://ibotpeaches.github.io/Apktool/install/ :
Quick Check
- Apktool 2.x (Versions after
1.5.2
)- Is Java 1.7 installed?
- Does executing java -version on command line / command prompt return 1.7?
- If not, please install Java 7 and make it the default.
Installation for Apktool 2.x
- Windows:
- Download Windows wrapper script (Right click, Save Link As
apktool.bat
) - Download apktool-2 (find newest here)
- Rename downloaded jar to
apktool.jar
- Move both files (
apktool.jar
&apktool.bat
) to your Windows directory (UsuallyC://Windows
) - If you do not have access to
C://Windows
, you may place the two files anywhere then add that directory to your Environment Variables System PATH variable. - Try running apktool via command prompt
- Download Windows wrapper script (Right click, Save Link As
- Linux:
- Download Linux wrapper script (Right click, Save Link As
apktool
) - Download apktool-2 (find newest here)
- Make sure you have the 32bit libraries (
ia32-libs
) downloaded and installed by your linux package manager, if you are on a 64bit unix system. - (This helps provide support for the 32bit native binary aapt, which is required by apktool)
- Rename downloaded jar to
apktool.jar
- Move both files (
apktool.jar
&apktool
) to/usr/local/bin
(root needed) - Make sure both files are executable (
chmod +x
) - Try running apktool via cli
- Download Linux wrapper script (Right click, Save Link As
- Mac OS X:
- Download Mac wrapper script (Right click, Save Link As
apktool
) - Download apktool-2 (find newest here)
- Rename downloaded jar to
apktool.jar
- Move both files (
apktool.jar
&apktool
) to/usr/local/bin
(root needed) - Make sure both files are executable (
chmod +x
) - Try running apktool via cli
- Download Mac wrapper script (Right click, Save Link As
Note - Wrapper scripts are not needed, but helpful so you don’t have to type java -jar apktool.jar over and over.
我这里没法把他们放在 bin 目录下, 而是放在了 /software/android/tools 目录下。
这样,我解压缩下载目录下的一个apk文件,就是下面命令:
/software/android/tools/apktool d ~/Downloads/com.supercell.clashofclans_v8.116.2-722_Android-4.0.3.apk
解压缩后的目录是: /software/android/tools/ 下面目录。
参数说明:
apktool d [demo.apk] // 参数是 d 而不是 -d。
./apktool
Apktool v2.0.3 - a tool for reengineering Android apk files
with smali v2.1.0 and baksmali v2.1.0
Copyright 2014 Ryszard Wi?niewski <[email protected]>
Updated by Connor Tumbleson [email protected]
usage: apktool
-advance,--advanced prints advance information.
-version,--version prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
-p,--frame-path <dir> Stores framework files into <dir>.
-t,--tag <tag> Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
-f,--force Force delete destination directory.
-o,--output <dir> The name of folder that gets written. Default is apk.out
-p,--frame-path <dir> Uses framework files located in <dir>.
-r,--no-res Do not decode resources.
-s,--no-src Do not decode sources.
-t,--frame-tag <tag> Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
-f,--force-all Skip changes detection and build all files.
-o,--output <dir> The name of apk that gets written. Default is dist/name.apk
-p,--frame-path <dir> Uses framework files located in <dir>.
For additional info, see: http://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali