> For the complete documentation index, see [llms.txt](https://docs.aiot.virbox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aiot.virbox.com/faq/apktool.md).

# 使用 Apktool 解压 APK 并打包

Android应用加固中，如果对apk中的SO文件进行加固，需首先使用 **apktool** 解压apk文件。

**apktool** 除了可以解压apk外，还可以在修改后重新打包。

## 功能

* 将apk解压为原来的形式（包括resources.arsc，class.dex，so等）
* 将解压的资源重新打包成apk
* 组织和处理依赖于框架资源的apk
* Smali调试
* 执行自动化任务

## 安装方式

访问 [https://ibotpeaches.github.io/Apktool/install](https://ibotpeaches.github.io/Apktool/install/)，根据开发环境选择对应版本。

## 使用方式

```
usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
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>.
```

## 解压apk

### 切换目录

![切换至apk所在目录](/files/-MDn3ZAnVnuYu4gbKA85)

### 解压apk

```
apktool d <file_apk>
```

![解压apk文件](/files/-MDn3yO-iWqp81HzHS5X)

解压后，会生成一个同名的文件夹

![解压后的文件夹](/files/-MDmxqPf1hoiPNTfvhnK)

### 查看SO文件

本范例的SO文件保存于C:\Program Files (x86)\apktool\angrybots5.5.3\lib\armeabi-v7a目录下，开发者可根据自己的实际情况定位SO文件目录。

![查看SO文件](/files/-MDmyYO8YRNXdn8aE8iU)

### SO加固

不同语言开发的SO文件加固方式不同，详情请访问：

{% content-ref url="/pages/-M9JNt\_JZGym5IN8TZYU" %}
[开发指南](/how-to-use.md)
{% endcontent-ref %}

## 打包apk

### 切换目录

![切换至解压文件所在目录](/files/-MDn4ArjKtEsK51LY92I)

### 打包apk

```
apktool b <app_path>
```

![打包apk文件](/files/-MDn4cz85KAExwX2hSSv)

### 查看apk文件

本范例的新apk文件保存于C:\Program Files (x86)\apktool\angrybots5.5.3\dist目录下，开发者可根据自己的实际情况定位apk所在目录。

![](/files/-MDn2YMNbmw4EF7ycWY2)

## 文件对比

![保护前后文件对比](/files/-MDn59NA1p1cDdQXOwVO)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aiot.virbox.com/faq/apktool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
