2020-01-15 18:05:38 +08:00
|
|
|
|
---
|
|
|
|
|
layout: post
|
|
|
|
|
title: "Aapt 命令说明"
|
|
|
|
|
subtitle: ""
|
|
|
|
|
description: "描述 Aapt 命令的功能和用法。"
|
|
|
|
|
excerpt: "Aapt 命令可用于查看 apk 包名、主 activity、版本等。"
|
2022-07-28 15:01:41 +08:00
|
|
|
|
date: 2022-07-28 12:00:00
|
2020-01-15 18:05:38 +08:00
|
|
|
|
author: "Rick Chan"
|
|
|
|
|
tags: ["Applications", "Aapt"]
|
|
|
|
|
categories: ["Software"]
|
|
|
|
|
published: true
|
|
|
|
|
---
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2022-04-29 13:20:16 +08:00
|
|
|
|
aapt 即 Android Asset Packaging Tool,在 SDK 的 build-tools 目录下。该工具可以查看,创建, 更新 ZIP 格式的文档附件(zip, jar, apk)。也可将资源文件编译成二进制文件。可以通过 aapt 的 dump 参数显示 apk 包中的信息。
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2022-04-29 13:20:16 +08:00
|
|
|
|
Ubuntu 可通过 apt 命令安装 aapt 工具:
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2022-07-28 15:01:41 +08:00
|
|
|
|
```bash
|
|
|
|
|
sudo apt install aapt
|
|
|
|
|
```
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
|
|
|
|
可通过 aapt badging 输出 apk 的包名,主 activity、版本等信息
|
|
|
|
|
|
2022-07-28 15:01:41 +08:00
|
|
|
|
```bash
|
|
|
|
|
aapt dump badging <apkname.apk> > <logfile>
|
|
|
|
|
```
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2020-09-07 17:47:52 +08:00
|
|
|
|
之后在 logfile 中搜索 package,后面的 name 就是包名了,搜 activity,可以获取到 主 activity,搜 launchable-activity 可得到 package 和 activity。
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2022-04-29 13:20:16 +08:00
|
|
|
|
aapt 的其他 dump 参数及说明如下:
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|
2020-09-28 16:48:24 +08:00
|
|
|
|
| Options | Description |
|
2019-01-24 13:55:24 +08:00
|
|
|
|
|----------------|-------------------------------------------------------|
|
|
|
|
|
| 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. |
|