APK反編譯、修改、重打包、簽名
1、反編譯:
java -jar apktool_2.0.0.jar d TestSMSDemo.apk
默認反編譯到TestSMSDemo文件夾下,apktool下載請點擊這里
2、修改AndroidManifest.xml
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".VideoApplication" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:uiOptions="splitActionBarWhenNarrow" android:debuggable="true"> <!-- 主要添加debuggable,為以后調試apk做準備-->
3、重新打包:
java -jar apktool_2.0.0.jar b TestSMSDemo(之前反編譯生成的文件夾名,如果是out請寫out)
默認會將文件重新打包到TestSMSDemo/dist目錄下
4、簽名:
1)生成keystore。可以使用命令行生成keystore,也可以使用Eclipse簽名一個demo生成keystore,記住保存位置就好了。
-
使用命令行生成:
</li> </ul>keytool -genkey -v -keystore mykeystore(可以任意名字) -alias linlin(別名,可以任意,但是在后面會用到這個別名,所以要記清楚) -keyalg RSA -validity 20000
然后根據提示輸入需要的內容。
-
使用Eclipse生成就不用說了,簽名apk的時候都用到,記住生成keystore保存位置。簡單易行。
</li> </ul>2)簽名apk
jarsigner -verbose -keystore mykeystore -signedjar android_signed.apk(目標名字) TestSMSDemo.apk(要簽名的apk) linlin(這個地方就是上面說要記住的別名 -alias,看有些例子上面這個地方字符串用‘ ’號引起來是錯誤的,直接寫字符串就好了)
附:
() 里面是說明文字,在使用命令時請忽視
為了方便記憶可以將-alias和keystore的名字一致。如果-alias跟keystore名字不一致,又忘記了寫的什么,可以使用Eclipse查看。具體方法就是打包程序,然后選擇該keystore,輸入密碼后會自動顯示alias的名字。如下圖所示:
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://code.google.com/p/android-apktool/
For smali/baksmali info, see: http://code.google.com/p/smali/ 用于Odex-dex后面說這個的使用error:
jarsigner: 找不到xxx的證書鏈。xxx必須引用包含私有密鑰和相應的公共 密鑰證書鏈的有效密鑰庫密鑰條目。
出現類型提示是因為alias沒有填寫正確。
使用aiqiyi客戶端測試,重新打包簽名后正常運行沒問題。
-