天天看点

apktool使用

首先,到官网下载apktool需要的工具:https://ibotpeaches.github.io/Apktool/.

下载地址:https://ibotpeaches.github.io/Apktool/install/

具体的安装步骤:

Installation for Apktool

  • 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.

说的很清楚了,我们下载的apktool工具需要重命名为apktool.jar,同时把apktool.bat也下载下来放在一个文件夹下。

apktool功能用法:

usage: apktool [-q|--quiet OR -v|--verbose] empty-framework-dir [options]  
 -f,--force              Force delete destination directory.
 -p,--frame-path <dir>   Stores framework files into <dir>.
           

上示例:

$ apktool d test.apk
I: Using Apktool 2.2.1 on test.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
$ apktool b test
I: Using Apktool 2.2.1 on test
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
           

反编译apk:

java -jar apktool.jar d demo.apk

编译成apk:

java -jar apktool.jar b -d demo -o debug.apk

签名方法:

jarsigner -verbose -keystore demo.keystore -signedjar test_signed.apk test.apk mykey

#    test_signed.apk是签名之后的文件

#    test.apk是需要签名的文件

#    mykey 昵称

例如:

jarsigner -verbose -keystore demo.keystore -signedjar test_signed.apk test.apk key_nickname