Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@caojianhua
Last active November 7, 2019 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caojianhua/753ec4e456b5ce7ec65a22d68ce5ba24 to your computer and use it in GitHub Desktop.
Save caojianhua/753ec4e456b5ce7ec65a22d68ce5ba24 to your computer and use it in GitHub Desktop.
计算jar包文件中的方法总数
#! /bin/sh
# 获得输入的jar文件
JAR_FILE=$1;
# 这里直接使用dx命令,是因为我已经提前配置好了环境变量,dx目录位于:
# $ANDROID_HOME/sdk/build-tools/android-4.3.1/dx
dx --dex --verbose --no-strict --output=temp.dex $JAR_FILE > /dev/null
# 计算jar包中的方法数
METHOD_COUNT=`cat temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'`
# 显示结果
echo $METHOD_COUNT
# 删除临时文件temp.dex
rm -f temp.dex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment