Apktool in Termux – Installation Commands and Usage Guide

Apktool is a command-line tool used for decoding and rebuilding Android APK files. It can decode an APK to view its resources and configuration files, and it can rebuild the files back into an APK. You can use it for Android development, app testing, and learning how Android applications are structured in a simple and practical way.

Here’s what you can do with Apktool in Termux:

  • Decode APK files.
  • View APK resources and configuration files.
  • Extract the AndroidManifest.xml file.
  • Rebuild decoded APK files.
  • Install framework files.
  • Use custom output directories.
  • Control decoding options.

Install Apktool in Termux

Run the commands below one by one to install Java and Apktool on your device.

First, update the Termux packages:

pkg update && pkg upgrade -y

Install Java:

pkg install openjdk-17 -y

Now install Apktool:

pkg install apktool -y

Check the installed version:

apktool --version

If the version is displayed, Apktool has been installed successfully.

Use Apktool in Termux

Before using Apktool, move to the directory where your APK file is stored. For example, if the APK is inside the Download folder:

cd /sdcard/Download

Decode an APK

Use the d or decode command to decode an APK:

apktool d app.apk

By default, Apktool creates a decoded app folder for the APK.

You can also specify your own output directory:

apktool d app.apk -o decoded-app

Force Apktool to delete an existing destination directory before decoding:

apktool d app.apk -f

Decode all source files, including unknown DEX files:

apktool d app.apk -a

Skip decoding Android resources:

apktool d app.apk -r

Skip decoding source files:

apktool d app.apk -s

Set the number of parallel jobs:

apktool d app.apk -j 4

Use a custom framework directory:

apktool d app.apk -p ~/framework

Use a specific framework tag:

apktool d app.apk -t custom

Rebuild an APK

After making changes to a decoded APK directory, use the b or build command to rebuild it:

apktool b decoded-app

The rebuilt APK is normally placed inside the dist directory.

You can choose a custom output file:

apktool b decoded-app -o rebuilt.apk

Force Apktool to rebuild all files:

apktool b decoded-app -f

Set the number of parallel jobs:

apktool b decoded-app -j 4

Use a custom framework directory while rebuilding:

apktool b decoded-app -p ~/framework

Install an Android Framework

Some APKs require framework files to decode correctly. You can install a framework APK using:

apktool if framework.apk

You can also use a custom framework directory:

apktool if framework.apk -p ~/framework

Add a custom framework tag:

apktool if framework.apk -t custom

Other Useful Commands

Display the Apktool help menu:

apktool h

You can also use:

apktool --help

Check the Apktool version:

apktool --version

Use quiet mode to reduce normal output:

apktool d app.apk -q

Use verbose mode for more detailed output:

apktool d app.apk -v

Basic APK Workflow

A simple workflow is to first decode an APK:

apktool d app.apk -o decoded-app

After making changes to the decoded files, rebuild the APK:

apktool b decoded-app -o rebuilt.apk

The rebuilt APK may need to be signed before it can be installed on an Android device. Signing is a separate process from decoding and rebuilding.

Note: Use Apktool only with APK files that you own or have permission to analyze or modify.

End Note

Apktool is a simple command-line tool that you can use to decode and rebuild APK files in the terminal. It is useful for quickly viewing Android application structures, testing APK files, and learning about Android app development in a simple way.

SHARE THIS POST: