获取apk包名

aapt dump badging apk | findstr launchable-activity

aapt dump badging apk | findstr package

 

aapt环境配置

https://blog.csdn.net/qq_16430735/article/details/50084625

41.Android aapt工具

Android aapt工具

aapt 介绍

aapt 环境配置

aapt list

aapt dump

aapt package

其他命令

aapt 介绍

可参考官方文档: http://www.androidcn.net/wiki/index.php/Reference/aapt

 

aapt stands for Android Asset Packaging Tool and is included in the tools/ directory of the SDK. This tool allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.

 

Though you probably won’t often use aapt directly, build scripts and IDE plugins can utilize this tool to package the apk file that constitutes an Android application.

 

For more usage details, open a terminal, go to the tools/ directory, and run the command:

 

Linux or Mac OS X:

./aapt

Windows:

aapt.exe

 

aapt 为 Android Asset Packaging Tool , 在SDK的tools/目录下. 该工具可以查看, 创建, 更新ZIP格式的文档附件(zip, jar, apk). 也可将资源文件编译成二进制文件。

 

尽管你可能没有直接使用过aapt工具, 但是build scripts和IDE插件会使用这个工具打包apk文件构成一个Android 应用程序.

 

获取更多的实用信息, 请打开终端控制台, 到tools/目录下, 执行命令:

Linux or Mac OS X:

./aapt

Windows:

aapt.exe

 

aapt 环境配置

aapt工具位于:sdk/buid-tools/android-[version]/aapt。

 

Windows环境的话,可以直接在环境变量里配置一个PATH,指定到sdk/buid-tools/android-[version]即可。

 

Mac环境的话,我用的是Oh My Zsh,所以直接vi ~/.zshrc,以下是我配置:

 

# Add Android build-tools AAPT variable

AAPT_HOME=/Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/build-tools/23.0.2

export AAPT_HOME

export PATH=$PATH:$AAPT_HOME

1

2

3

4

然后在命令行下输入:aapt。

 

 

可以看到 aapt 的所有命令,和命令对应有哪些参数。

 

aapt list

aapt l[ist] [-v] [-a] file.{zip,jar,apk}

List contents of Zip-compatible archive.

 

查看apk目录:

aapt l *.apk

 

 

查看apk目录,以表格形式输出:

aapt l -v *.apk

Method : 压缩形式 , Deflate 或 Stored 。

Ratio : 压缩率

CRC-32 : 循环冗余校验

 

 

详细查看apk目录:

aapt l -a *.apk

 

 

aapt dump

aapt d[ump] [–values] [–include-meta-data] WHAT file.{apk} [asset [asset …]]

strings Print the contents of the resource table string pool in the APK.

badging Print the label and icon for the app declared in APK.

permissions Print the permissions from the APK.

resources Print the resource table from the APK.

configurations Print the configurations in the APK.

xmltree Print the compiled xmls in the given assets.

xmlstrings Print the strings of the given compiled xml assets.

 

查看apk:package、sdkVersion、targetSdkVersion、application-label、launchable-activity、feature-group等信息:

aapt d badging *.apk

 

 

查看apk权限:

aapt d permissions *.apk

 

 

查看apk资源:

aapt d resources *.apk

 

 

查看apk配置:

aapt d configurations *.apk

 

 

查看xml的树形结构:

aapt d xmltree *.apk res/*.xml

 

 

查看xml中所有的string:

aapt d xmlstrings *.apk res/*.xml

 

 

查看信息后输出文件:

aapt d ... >*.txt

 

查看输出:

 

 

aapt package

生成R.java:

先定位到项目目录下

aapt package -m -J ~/temp/ -S app/src/main/res -I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar -M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml

-J ~/temp/ : 设置输出目录

-S app/src/main/res: 资源文件res目录

-I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar: android.jar路径

**-M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml:**AndroidManifest绝对路径

 

生成资源文件

还是先定位到项目目录下

aapt package -f -M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml -S app/src/main/res -A app/src/main/assets -I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar -F ~/log/resouces

**-M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml:**AndroidManifest绝对路径

-S app/src/main/res: 资源文件res目录

-A app/src/main/assets: assets目录

-I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar: android.jar路径

-F ~/log/resouces: resouces.arsc存放路径

 

其他命令

输出aapt版本

 

aapt v[ersion]

Print program version.

 

删除apk中指定文件

 

aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 …]

Delete specified files from Zip-compatible archive.

 

添加指定文件到apk中

 

aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 …]

Add specified files to Zip-compatible archive.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个工具前后用了好多天的时间查阅资料并不断修改才完成。本工具可以用于读取apk的大量信息,无其他依赖。可以直接通过命令行运行,也可以当作架使用。 命令行方式使用举例: 获取AndroidManifest.xml文件中定义的versionCode: java -jar ApkAnalysis.jar “apk路径” -versionCode 获取apk证书详情: java -jar ApkAnalysis.jar “apk路径” -certs 获取apk证书中的第一条的详情: java -jar ApkAnalysis.jar “apk路径” -certs 0 获取证书摘要(百度、高德地图等API中需要的那个SHA1): java -jar ApkAnalysis.jar “apk路径” -certs 0 SHA1 获取apk发布者信息: java -jar ApkAnalysis.jar “apk路径” -certs 0 issuer 获取apk声明的权限: java -jar ApkAnalysis.jar “apk路径” -permissions 当作为架使用时,通过 ApkAnalysis apkAnalysis = ApkAnalysis.getApkReader(apkFilePath); 获取ApkAnalysis的实例,然后就调用对应方法读取即可。相信都会使用自动补全等功能吧?那个会告诉你有哪些可用的方法,这里不例举了。 输入 java -jar ApkAnalysis.jar -help会给出如下提示,请慢慢研究。如果好用,请不吝评价一下,谢谢~至于源码么,会反编译的就反编译吧,我也拦不住的,纯Java写的,还是很好反编译的,也没有代码混淆过。感兴趣愿意一起交流的可以留言问我要,纯粹伸手党就算了。 Apk分析工具 v1.0.7 编译时JDK版本:1.6.0_33 当前JRE版本:1.6.0_33 作者:周骞 发布日期:2015-01-08 --------------------------------------------------- ApkAnalysis [-versionCode] [-versionName] [-packageName]... 可用的选项: -versionCode 版本号 -versionName 版本名称,如1.0.3 -packageName Apk名 -certs [index] [MD5|SHA1|issuer|subject|validity] 获取证书的信息 -verify 校验apk内文件的签名,并列出未通过校验的文件 -permissions 获取apk所需的权限 -features 获取apk所需的特性 -activities [detail] 获取apk所含的Activity -services [detail] 获取apk所含的Service -receivers [detail] 获取apk所含的静态Receiver -content [name] 获取AndroidManifest.xml中的内容 -extract 抽取apk中的文件 -h[elp] 显示此帮助信息 --------------------------------------------------- 如在程序中引用本,方法如下: ApkAnalysis apkAnalysis = ApkAnalysis.getApkReader(apkFilePath); 需要判断apkAnalysis是否为null,为null表示读取失败,不为null时即可调用getXX()获取数据

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值