### Install Node.js Dependencies
Source: https://apktool.org/wiki/meta/contributing
Run this command to install the necessary Node.js dependencies for the documentation lint check. Ensure you have Node.js and npm installed.
```bash
npm install
```
--------------------------------
### Install Frameworks with Apktool
Source: https://apktool.org/wiki/the-basics/frameworks
Demonstrates basic framework installation, tagging, and custom directory storage using the 'if' command.
```bash
$ apktool if framework-res.apk
I: Framework installed to: 1.apk
# pkgId of framework-res.apk determines the number. (which is 0x01)
$ apktool if com.htc.resources.apk
I: Framework installed to: 2.apk
# pkgId of com.htc.resources is 0x02
$ apktool if com.htc.resources.apk -t htc
I: Framework installed to: 2-htc.apk
# pkgId-tag.apk
$ apktool if framework-res.apk -p foo/bar
I: Framework installed to: foo/bar/1.apk
$ apktool if framework-res.apk -t baz -p foo/bar
I: Framework installed to: foo/bar/1-baz.apk
```
--------------------------------
### Install Apktool via Homebrew
Source: https://apktool.org/docs/install
Use this command to install Apktool if you are using Homebrew on macOS. Ensure Homebrew is installed first.
```bash
brew install apktool
```
--------------------------------
### Example Windows Clone Path
Source: https://apktool.org/docs/build
This is an example of a directory path on Windows for cloning the Apktool project. Ensure the total path length, including the project directory, does not exceed 37 characters to avoid limitations.
```text
C:/Users/Connor/Desktop/Apktool
```
--------------------------------
### Apktool Dummy Resource Example
Source: https://apktool.org/wiki/in-depth/resource-modes
Historically, Apktool created dummy resources to maintain static resource IDs when disassembly failed. This example shows the XML format for such dummy resources.
```xml
```
--------------------------------
### Build Command Usage Examples
Source: https://apktool.org/wiki/the-basics/building
Demonstrates various ways to invoke the build command, including specifying output files and handling directories.
```bash
$ apktool b foo.jar.out
# builds foo.jar.out folder into foo.jar.out/dist/foo.jar
$ apktool build foo.jar.out
# builds foo.jar.out folder into foo.jar.out/dist/foo.jar
$ apktool b bar
# builds bar folder into bar/dist/bar.apk
$ apktool b .
# builds current directory into ./dist
$ apktool b bar -o new_bar.apk
# builds bar folder into new_bar.apk
$ apktool b bar.apk
# WRONG: brut.androlib.AndrolibException: brut.directory.PathNotExist: apktool.yml
# Must use folder, not apk/jar file
```
--------------------------------
### Install Tagged Framework Files with Apktool
Source: https://apktool.org/wiki/in-depth/frameworks
Use the `apktool if` command with the `-t` flag to install framework files with custom tags. This is useful for organizing frameworks from different devices.
```bash
$ apktool if com.htc.resources.apk -t hero
I: Framework installed to: /home/brutall/apktool/framework/2-hero.apk
$ apktool if com.htc.resources.apk -t desire
I: Framework installed to: /home/brutall/apktool/framework/2-desire.apk
```
--------------------------------
### Compare Apktool 1.5.x and 2.0.0 Command Syntax
Source: https://apktool.org/blog/tags/release/page/17
Comparison of command-line syntax for installing frameworks, decoding, and building APKs between versions.
```bash
apktool if framework-res.apk tag
```
```bash
apktool if framework-res.apk -t tag
```
```bash
apktool d framework-res.apk output
```
```bash
apktool d framework.res.apk -o output
```
```bash
apktool b output new.apk
```
```bash
apktool b output -o new.apk
```
--------------------------------
### Decode APK After Framework Installation
Source: https://apktool.org/wiki/in-depth/frameworks
After successfully installing the necessary framework resources, you can now decode the target APK. Apktool will leverage both the default and installed framework files.
```bash
$ apktool d HtcContacts.apk
I: Loading resource table...
I: Decoding resources...
I: Loading resource table from file: /home/brutall/apktool/framework/1.apk
I: Loading resource table from file: /home/brutall/apktool/framework/2.apk
I: Copying assets and libs...
```
--------------------------------
### Install Manufacturer Framework
Source: https://apktool.org/wiki/in-depth/frameworks
Install manufacturer-specific framework resources by providing the APK file to Apktool. This allows Apktool to decode APKs that rely on these custom frameworks. The output indicates the package ID assigned to the installed framework.
```bash
$ apktool if com.htc.resources.apk
I: Framework installed to: 2.apk
```
--------------------------------
### GET /list-frameworks
Source: https://apktool.org/docs/cli-parameters
Lists framework files stored in the framework directory with options for filtering and path configuration.
```APIDOC
## GET list-frameworks
### Description
Lists framework files. By default, it lists untagged framework files.
### Method
GET
### Endpoint
apktool lf | list-frameworks {options}
### Parameters
#### Options
- **-a, --all** (flag) - Optional - Lists all framework files regardless of their tag.
- **-p, --frame-path
** (string) - Optional - Sets the folder framework files are read from.
- **-t, --frame-tag ** (string) - Optional - Lists framework files with the specified tag.
```
--------------------------------
### Dummy Resource Replacement Example
Source: https://apktool.org/wiki/in-depth/resource-modes
Illustrates how an unresolved resource name like '@null' might be replaced with a dummy resource identifier when using the 'dummy' mode in Apktool.
```xml
```
--------------------------------
### Hex Dump of resources.arsc Start
Source: https://apktool.org/wiki/advanced/resources-arsc
This is a hex dump of the initial bytes of a resources.arsc file, showing the first chunk header.
```text
00000000: 0200 0c00 f00b 0000 0100 0000 0100 1c00 ................
```
--------------------------------
### Disassembled Unknown Resource (v2.8.x)
Source: https://apktool.org/wiki/in-depth/resource-modes
This example shows how Apktool v2.8.x disassembled an unknown resource, incorrectly using '@null' for an attribute name. This behavior has been improved in later versions.
```xml
```
--------------------------------
### Remove Unresolved Resource Example
Source: https://apktool.org/wiki/in-depth/resource-modes
Demonstrates the 'remove' mode for Apktool, where unresolved resources are omitted from the disassembled output. This is the default behavior.
```xml
```
--------------------------------
### Decode Application with Tagged Frameworks using Apktool
Source: https://apktool.org/wiki/in-depth/frameworks
When decoding an application with `apktool d`, you can specify a tag using the `-t` flag to ensure Apktool uses the corresponding tagged framework file. This is automatically handled if the framework was installed with a tag.
```bash
$ apktool d HtcContacts.apk -t hero
I: Loading resource table...
I: Decoding resources...
I: Loading resource table from file: /home/brutall/apktool/framework/1.apk
I: Loading resource table from file: /home/brutall/apktool/framework/2-hero.apk
I: Copying assets and libs...
$ apktool d HtcContacts.apk -t desire
I: Loading resource table...
I: Decoding resources...
I: Loading resource table from file: /home/brutall/apktool/framework/1.apk
I: Loading resource table from file: /home/brutall/apktool/framework/2-desire.apk
I: Copying assets and libs...
```
--------------------------------
### Decode APK with Missing Framework
Source: https://apktool.org/wiki/in-depth/frameworks
This error occurs when Apktool cannot find the necessary framework resources to decode an APK. You must install the required framework files first.
```bash
$ apktool d HtcContacts.apk
I: Loading resource table...
I: Decoding resources...
I: Loading resource table from file: 1.apk
W: Could not decode attr value, using undecoded value instead: ns=android, name=drawable
W: Could not decode attr value, using undecoded value instead: ns=android, name=icon
Can't find framework resources for package of id: 2. You must install proper framework files, see project website for more info.
```
--------------------------------
### Keep Unresolved Resource Example
Source: https://apktool.org/wiki/in-depth/resource-modes
Shows the 'keep' mode in Apktool, where unresolved resources are retained but given valid, albeit generic, resource names. This preserves the resource entry while indicating it was unresolved.
```xml
```
--------------------------------
### Resources.arsc Segment After String Pool
Source: https://apktool.org/wiki/advanced/resources-arsc
A segment of the resources.arsc file showing data after the string pool. This includes a new chunk header and the start of a package name, indicating a RES_TABLE_PACKAGE_TYPE chunk.
```text
00000340: 0000 0000] 0002 2001 ac08 0000 7f00 0000 ...... .........
00000350: 6300 6f00 6d00 2e00 6900 6200 6f00 7400 c.o.m...i.b.o.t.
00000360: 7000 6500 6100 6300 6800 6500 7300 2e00 p.e.a.c.h.e.s...
00000370: 6100 7200 7300 6300 7400 6500 7300 7400 a.r.s.c.t.e.s.t.
```
--------------------------------
### Unzip an APK file
Source: https://apktool.org/wiki/the-basics/intro
Demonstrates the standard extraction of an APK archive using the unzip command.
```bash
$ unzip testapp.apk
Archive: testapp.apk
inflating: AndroidManifest.xml
inflating: classes.dex
extracting: res/drawable-hdpi/ic_launcher.png
inflating: res/xml/literals.xml
inflating: res/xml/references.xml
extracting: resources.arsc
```
--------------------------------
### Build Apktool With R8
Source: https://apktool.org/docs/build
Use this command to build the project with R8 optimization, requiring JDK 11 or higher. This command also generates a shadowJar file.
```bash
[./gradlew][gradlew.bat] build shadowJar proguard
```
--------------------------------
### Initialize Git Submodules
Source: https://apktool.org/blog/page/16
Command to initialize and update submodules for the Apktool development environment.
```bash
git submodule update --init --recursive
```
--------------------------------
### View Resources with aapt
Source: https://apktool.org/wiki/in-depth/resource-modes
Use the `aapt d resources` command to inspect the resources of an APK. This can reveal issues with resource resolution, such as invalid configurations.
```bash
➜ aapt d resources bugged.apk
Package Groups (1)
Package Group 0 id=0x7f packageCount=1 name=com.ibotpeaches.arsctest
Package 0 id=0x7f name=com.ibotpeaches.arsctest
type 0 configCount=1 entryCount=10
spec resource 0x7f010000 com.ibotpeaches.arsctest:color/black: flags=0x00000000
spec resource 0x7f010001 com.ibotpeaches.arsctest:color/purple_200: flags=0x00000000
spec resource 0x7f010002 com.ibotpeaches.arsctest:color/purple_500: flags=0x00000000
spec resource 0x7f010003 com.ibotpeaches.arsctest:color/purple_700: flags=0x00000000
spec resource 0x7f010004 com.ibotpeaches.arsctest:color/teal_200: flags=0x00000000
spec resource 0x7f010005 com.ibotpeaches.arsctest:color/teal_700: flags=0x00000000
spec resource 0x7f010006 com.ibotpeaches.arsctest:color/white: flags=0x00000000
INVALID TYPE CONFIG FOR RESOURCE 0x7f010007
INVALID TYPE CONFIG FOR RESOURCE 0x7f010008
spec resource 0x7f010009 com.ibotpeaches.arsctest:color/bugged: flags=0x00000000
```
--------------------------------
### Run Documentation Lint Check
Source: https://apktool.org/wiki/meta/contributing
Execute this command to run the lint check on the documentation files. This helps ensure the documentation follows the project's style guidelines.
```bash
npm run lint
```
--------------------------------
### Common Command Options
Source: https://apktool.org/docs/cli-parameters
Global options applicable to all Apktool commands.
```APIDOC
## Common Options
### Description
Options that can be used with any Apktool command.
### Parameters
- **-q, --quiet** (flag) - Optional - Suppresses output.
- **-v, --verbose** (flag) - Optional - Enables verbose output, including log messages tagged with FINE.
```
--------------------------------
### Decode APK or JAR files
Source: https://apktool.org/wiki/the-basics/decoding
Use the d or decode command to decompile files. Specify an output directory using the -o flag.
```bash
$ apktool d foo.jar
# decodes foo.jar to foo.jar.out folder
$ apktool decode foo.jar
# decodes foo.jar to foo.jar.out folder
$ apktool d bar.apk
# decodes bar.apk to bar folder
$ apktool decode bar.apk
# decodes bar.apk to bar folder
$ apktool d bar.apk -o baz
# decodes bar.apk to baz folder
```
--------------------------------
### Build Apktool Without R8
Source: https://apktool.org/docs/build
Use this command to build the project without R8 optimization, suitable for JDK versions greater than 8. This generates a shadowJar file.
```bash
[./gradlew][gradlew.bat] build shadowJar
```
--------------------------------
### Remove Old Framework Directory
Source: https://apktool.org/blog/apktool-2.3.4
Use this command to remove the old internal framework file before updating. This is a necessary step for the new release.
```bash
apktool empty-framework-dir
```
--------------------------------
### Make files executable on Linux/Mac
Source: https://apktool.org/docs/install
After moving the Apktool files to the appropriate directory on Linux or Mac, use this command to make them executable. This is required for running Apktool from the command line.
```bash
chmod +x
```
--------------------------------
### Disassemble Android APK with Apktool
Source: https://apktool.org/
Use this command to disassemble an Android APK file. It decodes resources and manifest for inspection.
```bash
$ apktool d test.apk
I: Using Apktool 3.0.1 on test.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
```
--------------------------------
### Assemble Disassembled Code into Android APK with Apktool
Source: https://apktool.org/
Use this command to reassemble disassembled code and resources back into an Android APK file. This is useful for modifying applications.
```bash
$ apktool b test
I: Using Apktool 3.0.1 on test
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
```
--------------------------------
### Decompile an APK with Apktool
Source: https://apktool.org/wiki/the-basics/intro
Uses the apktool d command to decode an APK file into its source components.
```bash
$ apktool d testapp.apk
I: Using Apktool 2.0.0 on testapp.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
```
--------------------------------
### Remove Framework File
Source: https://apktool.org/blog/page/16
Path to the framework file that requires manual removal due to internal API updates.
```bash
$HOME/apktool/framework/1.apk
```
--------------------------------
### Decoded AndroidManifest.xml
Source: https://apktool.org/wiki/the-basics/intro
Displays the human-readable XML output generated after decoding an APK.
```xml
```
--------------------------------
### Fix Documentation Lint Issues
Source: https://apktool.org/wiki/meta/contributing
Use this command to automatically fix most of the issues identified by the documentation lint check. This is a convenient way to maintain code style consistency.
```bash
npm run lint:fix
```
--------------------------------
### ResTable_package_header Structure
Source: https://apktool.org/wiki/advanced/resources-arsc
Details the header for a ResTable_package chunk, which represents a package within the resource table. It includes the package ID, name, and offsets to symbol tables.
```text
Package Id| 4 bytes| Package Id
Package Name| Variable| Package Name, null terminated
Type String Offset| 4 bytes| Offset to the type symbol table, may be zero if inheriting from another package
Last Public Type String Offset| 4 bytes| Last index in the above table of public types
Key Symbol Offset| 4 bytes| Offset to the key symbol table, may be zero if inheriting from another package
Last Public Key Symbol Offset| 4 bytes| Last index in the above table of key symbols
Type Id Offset| 4 bytes| Offset to the specific type ids for split apks
```
--------------------------------
### ResTable_header Structure
Source: https://apktool.org/wiki/advanced/resources-arsc
Describes the header for a ResTable_type chunk, which contains resource tables. It indicates the number of packages that follow within the file.
```text
Header| 8 bytes| The type of the chunk
Package Count| 4 bytes| The number of packages
```
--------------------------------
### ResChunk_header Structure
Source: https://apktool.org/wiki/advanced/resources-arsc
Defines the common header structure for all chunks within the resources.arsc file. It specifies the type, size of the header itself, and the total size of the chunk.
```text
Type| 2 bytes| The type of the chunk
Header Size| 2 bytes| The size of the header
Size| 4 bytes| The size of the chunk
```