Coder Social home page Coder Social logo

apkcal's Introduction

apkcal(apk/jar中方法数统计工具)

1、工具用途?

对Android APK、Jar包中的如下类型进行统计:
1)、class:类数
2)、field:字段数
3)、method:方法数
4)、string:字符串数

能对单个package进行统计,也能对package进行深度递归(包括所有子package)统计,也能对apk或jar文件进行总量统计

2、统计的目的?

因为在Android Dex File Format中,这些东西都有一个65536大小的限制;即:单个dex文件中,方法数量(等)不能超过这个数值。

3、如何配置?

1)、配置ADT的platform-tools和tools环境变量

2)、下载工具,解压后放到一个目录,并保证脚本可执行,比如:

	cp -r apkcal ~/Document/Tool/apkcal
	chmod -R 0755 ~/Document/Tool/apkcal/

3)、为apkcal.sh建立软链接:

	cd /usr/local/bin
	ln -s ~/Document/Tool/apkcal/apkcal.sh apkcal

4)、切换到任意目录,apkcal命令已可用

4、如何使用?

1)、查看帮助

	apkcal -h

以上命令将输出:

用法:
apkcal type=[type] deep=[deep] your_apk_path "your_package_list"

  type:统计类型,可选:[class|field|method|string]
  deep:是否进行package深度扫描统计,可选:[0|1] 默认:0

例:
apkcal type=method ../tieba.apk "com.baidu.tieba.frs com.baidu.tieba.pb"

2)、统计tiebaAll.apk文件中"com.baidu.tieba.account"包下的方法数

	apkcal type=method tiebaAll/tiebaAll.apk "com.baidu.tieba.account"

以上命令将输出:

开始进行apk文件中【 method 数】的统计...
创建临时目录成功...
解压apk文件并提取dex文件成功...
反编译dex文件成功...

  com.baidu.tieba.account 	: 872

删除临时目录成功,统计完成!

3)、深度统计tiebaAll.apk文件中"com.baidu.tieba.account"包下的方法数

	apkcal type=method deep=1 tiebaAll/tiebaAll.apk "com.baidu.tieba.account"

以上命令将输出:

开始进行apk文件中【 method 数】的统计...
创建临时目录成功...
解压apk文件并提取dex文件成功...
反编译dex文件成功...

  com/baidu/tieba/account 			: 872
  com/baidu/tieba/account/appeal 	: 126
  com/baidu/tieba/account/forbid 	: 144

删除临时目录成功,统计完成!

4)、同时统计多个包,包名之间用空格分开即可

	apkcal type=method tiebaAll/tiebaAll.apk "com.baidu.tieba.account com.baidu.tieba.frs com.baidu.tieba.pb"

5)、统计class的数量

	apkcal type=class deep=1 tiebaAll/tiebaAll.apk "com.baidu.tieba.account"

6)、不输入包名的情况下,则是对整个apk中所有的package都统计(总量)

	apkcal type=class tiebaAll/tiebaAll.apk

这种情况下,deep=1无效,即:不会进行所有package的深度遍历(因为package数量太多,实在太卡)

7)、jar文件的统计和apk完全一样,如:

	apkcal type=class galaxy-lite-1.0.0.jar

输出:

开始进行此文件中【 class 数】的统计...
创建临时目录成功...
反编译dex文件成功...

  all 	: 17

删除临时目录成功,统计完成!

5、意见反馈

Author:zhaoxianlie

Feedback:http://www.baidufe.com/item/1e0722b7ad2286a1aae6.html#comment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.