Apktool已更新到2.0.x,与以往1.5.2的区别及使用

时间真快,一转眼apktool工具已从1.5.2升级到2.0.1,今天也是因一个项目必须要使用高版本apktool才能正常拆包( Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file ),所以去更新了一下,发现apktool这次的更新比较牛哔哔,首先速度上真快了好了,我们之前的一个项目50M大概解包要5分钟(-_-! 应该不是电脑比较老的原因吧)现在100M的2~3分钟的样子吧,很速度。其次是一些参数上做了调整,以及配置信息上也做了调整(如versionCode、versionName的修改位置)

1、解包速度

刚刚也说了,速度提升真的特别明显,至少在我电脑上是特明显。

 

2、系统资源

之前1.5.2以上版本,抢占系统资源特别严重。新版本,很轻松,占用资源很少。

 

3、apktool参数的变化

1.5.2 参数

2.0.x 参数

d [ecode] [OPTS] <file.apk> [<dir>]
   ….细小参数不多说了
b [uild] [OPTS] [<app_path>] [<out_file>]
   ….细小参数不多说了

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

  apktool 执行 b [uild] 操作时,也就是将文件夹打回未签名apk时,需要加-o参数(我这边不加的时候找不到生成的apk)
apktool  b kinggoo_testsrc -o test kinggoo_test_unsign.apk

4、游戏内配置参数保存位置的修改

 

1.5.2

2.0.x

versionCode

versionName

versionCode 、versionName该版本时会存在于AndroidManifest.xml文件<manifest>标签内的一个属性值。

versionCodeversionName将不再保存于AndroidManifest.xml的<manifest>标签内了。而是保存在与AndroidManifest.xml同级下的apktool.yml文件内。

apktool.yml文件格式

 

 

version: 1.5.2
apkFileName: kinggoo_com.apk
isFrameworkApk: false
usesFramework:
  ids:
  – 1
sdkInfo:
  minSdkVersion: ’14’
  targetSdkVersion: ’19’
packageInfo:
  cur_package: com.kinggoo.test
  orig_package: com.kinggoo.test
compressionType: false

version: 2.0.1
apkFileName: kinggoo_com.apk
isFrameworkApk: false
usesFramework:
  ids:
  – 1
sdkInfo:
  minSdkVersion: ’14’
  targetSdkVersion: ’19’
packageInfo:
  forced-package-id: ‘127’
versionInfo:
  versionCode: ‘20300’
  versionName: 2.3.0

compressionType: false
sharedLibrary: false

apktool.yml 内容有上一个版本比:
SdkInfo – Used to repopulate the sdk information in AndroidManifest.xml since newer aapt requires version information to be passed via parameter
packageInfo – Used to help support Android 4.2 renamed manifest feature. Automatically detects differences between resource and manifest and performs automatic –rename-manifest-package on [b]uild
versionInfo – Used to repopulate the version information in AndroidManifest.xml since newer aapt requires version information to be passed via parameter
compressionType – Used to determine the compression that resources.arsc had on the original apk in order to replicate during [b]uild
unknownFiles – Used to record name/location of non-standard files in an apk in order to place correctly on rebuilt apk
sharedLibrary – Used to help support Android 5 shared library feature by automatically detecting shared libraries and using –shared-lib on [b]uild

5、拆包后文件结构变化

很明显多了一个文件original,官方是这样解释的
image

目录结构

1.5.2

2.0.x

image image

 

apktool.jar 2.0.1下载地址

链接: http://pan.baidu.com/s/1o6rcg90 密码: pnsc

 

参考

各版本安装资料

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)
- THE END -
版权声明:
转载原创文章请注明,文章出处:http://kinggoo.com
原文地址:http://kinggoo.com/android-apktool2.htm
发表评论?

0 条评论。

发表评论