ApkTool反汇编工具的介绍和安装

简介: Android apktool是一个用来处理APK文件的工具,可以对APK进行反编译生成程序的源代码和图片、XML配置、语言资源等文件,也可以添加新的功能到APK文件中。用该工具来汉化Android软件然后重新打包发布是相当简单的。

1、安装
   1).首先安装需要JAVA环境,先下载JDK/JRE,点击下载,已经有JAVA环境的可跳过此步

   2).到code.google上下载apktool.jar以及相关文件:http://code.google.com/p/android-apktool/downloads/list
点击下载apktool1.4.3.tar.bz2  和 apktool-install-windows-r04-brut1.tar.bz2

   3).解压apktool-install-windows-r04-brut1.tar.bz2到任意文件夹,然后解压apktool1.4.3.tar.bz2,把apktool.jar拷贝至apktool-install-windows-r04-brut1.tar.bz2解压所在的文件夹下,此时文件下有aapt.exe、apktool.bat及apktool.jar三个应用。

   4).点击开始菜单,运行,输入CMD回车,用cd命令转到刚刚解压的D:\My Documents\Desktop\apktool-install-windows-r04-brut1所在的文件夹,输入apktool,出现如下命令即说明安装成功(以下信息,即apktool使用命令)。
COMMANDs are:  
 
    d[ecode] [OPTS] [ ]  
        Decode to .  
 
        OPTS:  
 
        -s, --no-src  
            Do not decode sources.  
        -r, --no-res  
            Do not decode resources.  
        -d, --debug  
            Decode in debug mode. Check project page for more info.  
        -f, --force  
            Force delete destination directory.  
        -t , --frame-tag  
            Try to use framework files tagged by .  
        --keep-broken-res  
            Use if there was an error and some resources were dropped, e.g.:  
            "Invalid config flags detected. Dropping resources", but you  
            want to decode them anyway, even with errors. You will have to  
            fix them manually before building.  
    b[uild] [OPTS] [] []  
        Build an apk from already decoded application located in .  
 
        It will automatically detect, whether files was changed and perform  
        needed steps only.  
 
        If you omit then current directory will be used.  
        If you omit then /dist/  
        will be used.  
 
        OPTS:  
 
        -f, --force-all  
            Skip changes detection and build all files.  
        -d, --debug  
            Build in debug mode. Check project page for more info.  
 
    if|install-framework <framework.apk> []  
        Install framework file to your system.   2、使用

  1).解压APK
D:\My Documents\Desktop\apktool-install-windows-r04-brut1>apktool d F:\document\APK\PushAd.apk F:\document\app
源文件:F:\document\APK\PushAd.apk
解压目录:F:\document\app

Java代码

I: Baksmaling...  
I: Loading resource table...  
I: Loaded.  
I: Loading resource table from file: D:\My Documents\apktool\framework\1.apk  
I: Loaded.  
I: Decoding file-resources...  
I: Decoding values*/* XMLs...  
I: Done.  
I: Copying assets and libs...  

  2).打包APK
D:\My Documents\Desktop\apktool-install-windows-r04-brut1>apktool b F:\document\app F:\\document\\app.apk
源文件:F:\\document\\app
打包目录:F:\document\app.apk

Java代码

I: Checking whether sources has changed...  
I: Smaling...  
I: Checking whether resources has changed...  
I: Building resources...  
I: Building apk file... </framework.apk>
官网上关于ApkTool的介绍的安装相关:

Apktool  

A tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. Also it makes working with an app easier because of project-like file structure and automation of some repetitive tasks like building apk, etc.

It is NOT intended for piracy and other non-legal uses. It could be used for localizing, adding some features or support for custom platforms, analyzing applications and much more.

Features

  • Disassembling resources to nearly original form (including resources.arscclasses.dex9.png. and XMLs)
  • Rebuilding decoded resources back to binary APK/JAR
  • Organizing and handling APKs that depend on framework resources
  • Smali Debugging (to be removed in 2.1.0 in favor of IdeaSmali)
  • Helping with repetitive tasks

Requirements

  • Java 7 (JRE 1.7)
  • Basic knowledge of Android SDK, AAPT and smali

Install Instructions

Quick Check

  • Apktool 2.x (Versions after 1.5.2)
    1. Is Java 1.7 installed?
    2. Does executing java -version on command line / command prompt return 1.7?
    3. If not, please install Java 7 and make it the default.
  • Apktool 1.x (Versions prior to 1.5.2)
    1. Is Java 1.6 or higher installed?
    2. Does executing java -version on command line / command prompt return 1.6 or above?
    3. If not, please install Java 6 or Java 7.

Installation for Apktool 2.x

  • Windows:
    1. Download Windows wrapper script (Right click, Save Link As apktool.bat)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool.bat) to your Windows directory (Usually C://Windows)
    5. 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.
    6. Try running apktool via command prompt
  • Linux:
    1. Download Linux wrapper script (Right click, Save Link As apktool)
    2. Download apktool-2 (find newest here)
    3. 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.
    4. (This helps provide support for the 32bit native binary aapt, which is required by apktool)
    5. Rename downloaded jar to apktool.jar
    6. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
    7. Make sure both files are executable (chmod +x)
    8. Try running apktool via cli
  • Mac OS X:
    1. Download Mac wrapper script (Right click, Save Link As apktool)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
    5. Make sure both files are executable (chmod +x)
    6. Try running apktool via cli

Note - Wrapper scripts are not needed, but helpful so you don’t have to type java -jar apktool.jar over and over.

Installation for Apktool 1.x

  • Windows:
    1. Download apktool-install-windows-* file
    2. Download apktool-* file
    3. Unpack both to your Windows directory
  • Linux:
    1. Download apktool-install-linux-* file
    2. Download apktool-* file
    3. Unpack both to /usr/local/bin directory (you must have root permissions)
  • Mac OS X:
    1. Download apktool-install-macos-* file
    2. Download apktool-* file
    3. Unpack both to /usr/local/bin directory (you must have root permissions)

你可能感兴趣的:(ApkTool反汇编工具的介绍和安装)