一、ApkToolBox
首先介紹一個工具套件:ApkToolBox
該工具箱綜 合了 apk 反編譯系列元件,其中apk回編譯過程中簽名是使用debug.keystore進行的簽名,如果想生成不沒簽名的apk則隻需把tool目錄下的debug.keystore 檔案删除或重命名。
下載下傳位址: https://download.csdn.net/download/u013964761/15118183
二、apktool.jar 使用
1、apktool的配置
首先需要apktool.jar 和apktool.bat
apktool.jar位址在:https://bitbucket.org/iBotPeaches/apktool/downloads/
apktool.bat位址在:https://ibotpeaches.github.io/Apktool/install/
(1)下載下傳後将其放在 C:\Windows 下
放到 C:\Windows 可以直接使用通過cmd 使用 apktool 指令進行調用
(2)放到指定目錄,使用時進入到對應目錄,使用java -jar apktool ........ 方式使用
apktool使用
windows 下 cd 進入 使用者\apktool
例如:C:\Users\xxx\apktool
輸入apktool 即可看到下方提示
C:\Users\xxxx> 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
2.apk拆包指令
apktool d {apk路徑} 注:拆包的路徑在Users\xxx 下
指定路徑
apktool d {apk路徑} -o F:\xxxx 注:不要使用已存在的檔案夾
例如 : apktool d F:\xxxx\xxx.apk -o F:\xxx
3.apk打包指令
apktool b {拆包目錄} -o {儲存apk的路徑}
例如 : apktool b F:\xxx -o F:\xxxx\xxx.apk
4.拿到生成後未簽名的apk 加入debug簽名
三 、未簽名的apk 加入簽名
(1)jarsigner 目錄位址在 android\jre\bin 目錄下,通過cd 進入jarsigner 目錄位址進行使用
(2)環境變量設定正确的情況下,直接在cmd中 jarsigner 也能正常調用
jarsigner -verbose -keystore ~/Workspace/my.keystore -signedjar ./emptyapk-release-signed.apk ./emptyapk-release-unsigned.apk alias
jarsigner工具的指令格式是:
jarsigner -verbose -keystore [您的私鑰存放路徑] -signedjar [簽名後檔案存放路徑] [未簽名的檔案路徑] [您的證書名稱]
#jarsigner的參數說明
-keystore 參數指定您的私鑰的絕對路徑,例如:/Users/mac/Desktop/my.keystore
-signedjar 參數指定簽名後apk檔案存放絕對的路徑,例如 /Users/mac/Desktop/signed.apk
[未簽名的檔案路徑] 指定要簽名apk檔案的絕對路徑,例如 /Users/mac/Desktop/emptyapk-release-unsigned.apk
[您的證書名稱] 是指您建立密鑰時,您設定的證書名稱也就是Alias
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHL6tmeNhXTU1kMFpHW4Z0MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL5ATMxETN0ATM4ATMxgTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)