1. Project Overview & Quickstart (iBotPeaches/Apktool)
Apktool
This is the repository for Apktool. The website is at the apktool.org repository.
Apktool is a tool for reverse engineering third-party, closed, binary, Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes it possible to debug smali code step-by-step. It also makes working with apps easier thanks to project-like file structure and automation of some repetitive tasks such as building apk, etc.
Apktool is NOT intended for piracy and other non-legal uses. It could be used for localizing and adding features, adding support for custom platforms, and other GOOD purposes. Just try to be fair with the authors of an app, that you use and probably like.
Branches
main- Apktool 3.x branch2.x- Maintenance branch for Apktool 2.x releases
Support
Security Vulnerabilities
If you discover a security vulnerability within Apktool, please send an e-mail to Connor Tumbleson at connor.tumbleson(at)gmail.com. All security vulnerabilities will be promptly addressed.
Links
- Downloads
- Downloads Mirror
- How to Build
- Documentation
- Bug Reports
- Changelog/Information
- XDA Post
- Source (GitHub)
- Source (Bitbucket)
Sponsors
Special thanks goes to the following sponsors:
Sourcetoad
Sourcetoad is an award-winning software and app development firm committed to the co-creation of technology solutions that solve complex business problems, delight users, and help our clients achieve their goals.
Emerge Tools
Emerge Tools is a suite of revolutionary products designed to supercharge mobile apps and the teams that build them.
2. Official Technical Reference & Guides (iBotPeaches/apktool.org)
File: README.md
Apktool Website
This is the https://apktool.org website written in Docusaurus. The tool is at the Apktool repository.
Installation
npm installLocal Development
npm run startThis command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
File: docs/build.mdx
title: Build Guide sidebar_position: 1
Build Apktool
Apktool is a project that contains a collection of subprojects and dependencies.
- brut.apktool.lib - Main Library
- brut.apktool.cli - CLI Interface
- brut.j.dir - Utility
- brut.j.util - Utility
- brut.j.common - Utility
Requirements
Build Steps
First clone the repository from GitHub
- Navigate to the Apktool folder and for the remaining steps use
./gradlewfor Unix based systems orgradlew.batfor Windows. - You can build the project in two ways:
:::info
v2.10 moved from Proguard to R8, but kept the naming to Proguard for the time being. This will be updated in the future.
:::
Without R8 (JDK > 8)
[./gradlew][gradlew.bat] build shadowJar- Creating a jar file:
brut.apktool/apktool-cli/build/libs/apktool-cli-all.jar.
With R8 (JDK > 11):
[./gradlew][gradlew.bat] build shadowJar proguard- Creating a jar file:
brut.apktool/apktool-cli/build/libs/apktool-vXXX.jar.
Windows Requirements
:::caution
Be aware of directory path length limitations on Windows.
:::
Windows has some limitations regarding max filepath. At one location in Apktool, we have a 218 character directory path
which means due to the limitation of max 255 characters on Windows we need to enforce some requirements.
This leaves 37 characters total to clone the project on Windows. For example, I can clone this project to the location
C:/Users/Connor/Desktop/ApktoolThis is 31 characters, which allows Apktool to be cloned properly. Cloning the project into a directory longer than 37
characters will not work.
File: docs/cli-parameters.mdx
title: CLI Parameters sidebar_position: 3
Utility Options
Options used for utility commands (apktool {options})
h, help- Dumps out all usage output.
v, version- Outputs the current software version. (Ex: 1.5.2)
Decoding Options
Options used for decoding commands (apktool d file.apk {options})
-a, --all-src- Disassembles all dex files, including unknown ones.
- Includes dex files that aren't
classes*.dexlocated at the root.
- Includes dex files that aren't
-f, --force- Forces the deletion of the destination directory.
--ignore-raw-values- Ignore raw attribute values in XML resource files.
- By default, raw values are respected if originally preserved.
-j, --jobs <NUM>- Sets the number of threads to use when parallel operations are available.
- Defaults to the number of processors available, with a max of 8.
--keep-broken-res- Use if an error was thrown and some resources were dropped and you want to decode them anyway.
- E.g.
Invalid config flags detected. Dropping resources. - You will have to fix them manually before building.
- E.g.
-l, --lib :<location>- Use to specify a dynamic library location.
- E.g.
--lib com.google.android.test.shared_library:/tmp/shared_library.apk - This can be called multiple times to add multiple libraries.
- E.g.
--match-original- Matches the generated files as close as possible to the originals.
- Comes at the cost of possibly preventing re-build.
--no-assets- Prevents decoding/copying unknown asset files.
--no-debug-info- Prevents baksmali from writing out debug info. (
.local,.param,.line, etc.).
-o, --output <DIR>- Sets the name of the output directory.
- The Default is
apk.out.
- The Default is
--only-manifest- Only decode
AndroidManifest.xmlwithout resources.
-p, --frame-path <DIR>- Sets the folder framework files are stored/read from.
-r, --no-res- Prevents decompiling resources.
- Keeps
resources.arscintact.
- Keeps
--res-resolve-mode <mode>- Sets the mode used when resolving resources.
default- Adds dummy entries only for referenced resources that cannot be resolved.greedy- Adds dummy entries for all missing resources in the resource table, including unreferenced resources.lazy- Ignores missing resources, including referenced resources that cannot be resolved.
-s, --no-src- Prevents disassembling dex files.
- Leaves the dex files untouched and moves them upon build.
-t, --frame-tag <TAG>- Uses framework files tagged by
TAG.
Building Options
Options used for building commands (apktool b folder {options})
--aapt <FILE>- Loads aapt2 binaries from the specified location.
- These are used instead of the internal version.
--copy-original- Copies the original
AndroidManifest.xmlandMETA-INF.
--debuggable- Adds
debuggable="true"toAndroidManifest.xml.
-f, --force- Overwrites existing files during build.
- Includes resources and sources.
-j, --jobs <NUM>- Sets the number of threads to use when parallel operations are available.
- Defaults to the number of processors available, with a max of 8.
-l, --lib :<location>- Use to specify a dynamic library location.
- E.g.
--lib com.google.android.test.shared_library:/tmp/shared_library.apk - This can be called multiple times to add multiple libraries.
- E.g.
--net-sec-conf- Adds a generic Network Security Configuration file in the apk.
--no-apk- Disables repacking of the built files into a new apk.
--no-crunch- Disables crunching resource files during build.
- This prevents automatic bitmap optimization by aapt/aapt2.
-o, --output <FILE>- Sets the name of the output apk.
- The Default is
dist/{apkname}.apk.
- The Default is
-p, --frame-path <DIR>- Sets the folder framework files are stored/read from.
Install Framework Options
Options used for install-framework commands (apktool if|install-framework {options})
-p, --frame-path <DIR>- Sets the folder framework files are stored/read from.
-t, --frame-tag <TAG>- Suffixes framework files with
TAG.
Clean Frameworks Options
- Cleans untagged framework files by default.
Options used for clean-frameworks commands (apktool cf|clean-frameworks {options})
-a, --all- Cleans all framework files regardless of their tag.
-p, --frame-path <DIR>- Sets the folder framework files are read from.
-t, --frame-tag <TAG>- Cleans framework files with the specified tag.
List Framework Directory Options
- Lists untagged framework files by default.
Options used for list-frameworks commands (apktool lf|list-frameworks {options})
-a, --all- Lists all framework files regardless of their tag.
-p, --frame-path <DIR>- Sets the folder framework files are read from.
-t, --frame-tag <TAG>- Lists framework files with the specified tag.
Common Options
Options that can be used with any command
-q, --quiet- Quiet output.
-v, --verbose- Verbose output.
- Includes any log messages tagged with
FINE.
- Includes any log messages tagged with
File: docs/faq.mdx
title: FAQ sidebar_position: 4
Is it possible to run Apktool on an Android device?
Sadly not officially, there are some incompatibilities with running the aapt binary on Android.
Additionally, older builds of Android have problems with using the java.nio library. Unofficial
packages have only succeeded with cross-compiling binaries.
Where can I download the source of Apktool?
From either the GitHub or Bitbucket repositories.
The resulting APK is much smaller than the original. Is something wrong?
There are a few reasons this might occur.
- Apktool builds unsigned APKs. This means some directories and files like
META-INFare missing. - Updated build process - Apktool uses modern versions of
aapt/aapt2which may reduce file sizes.
There is no `META-INF` directory in the resulting APK. Is this ok?
Yes, META-INF contains the APK's signatures. After modifying an APK it is no longer signed. You
can use -c / --copy-original to retain these signatures. However, -c will use the originalAndroidManifest.xml and is only capable of working with the original APK signature v1 scheme.
What are "Magic APKs"?
There are some APKs that are built with modified build tools intended for specific OEMs. These APKs
are not built with regular AOSP tools and are not compatible with Apktool. Apktool will not be
able to decode or build these APKs.
Could I integrate Apktool into my own project? Could I modify it? Do I have to credit you?
The Apache license, which Apktool uses, answers all these questions.
- Yes, you can redistribute and/or modify Apktool without permission.
- However, it would be nice to add contributors (
brut.all,iBotPeaches,JesusFreke) to your credits.
Where does Apktool store framework files?
- Windows:
$HOME/AppData/Local/apktool - Mac:
$HOME/Library/apktool - Linux:
$HOME/.local/share/apktool
File: docs/install.mdx
sidebar_position: 2
Install Guide
:::info
A minimum of Java 8 is required to run Apktool.
:::
Windows
:::info
As Windows is case-insensitive please adjust case sensitivity for correct operation.
:::
- Download the Windows wrapper script. (Right click, Save Link As
apktool.bat) - Download the latest version of Apktool.
- Rename downloaded jar to
apktool.jar. - Move both
apktool.jarandapktool.batto your Windows directory. (UsuallyC://Windows) - If you do not have access to
C://Windows, you can place the two files anywhere and add that directory to your Environment Variables System PATH variable. - Try running
apktoolvia the command prompt.
Linux
- Download the Linux wrapper script. (Right click, Save Link As
apktool) - Download the latest version of Apktool.
- Rename the downloaded jar to
apktool.jar. - Move both
apktool.jarandapktoolto/usr/local/bin. (root needed) - Make sure both files are executable. (
chmod +x) - Try running
apktoolvia CLI.
Mac
- Download the Mac wrapper script. (Right click, Save Link As
apktool) - Download the latest version of Apktool.
- Rename the downloaded jar to
apktool.jar. - Move both
apktool.jarandapktoolto/usr/local/bin. (root needed) - Make sure both files are executable. (
chmod +x) - Try running
apktoolvia CLI.
Brew
- Install Homebrew as described in this page.
- Execute the command
brew install apktoolin the terminal. - Try running
apktoolvia CLI.
:::tip
Wrapper scripts are not needed but they are helpful, so you don't have to type java -jar apktool.jar repeatedly.
:::
File: docs/unreleased.mdx
title: Upcoming Release
:::info
The changelog of the upcoming release, subject to change prior to finalization.
:::
- [#4175] Move required build version to JDK 17.
- [#4155] Move to Gradle 9.
- [#4201] Support decoding to an empty folder. (Thanks IgorEisberg & iTrooz)
- [#4177] Improve performance and handling of UTF-8 in
apktool.yml. (Thanks IgorEisberg) - [#4205] Upgrade
xmlunit-legacyto2.13.0. - [#4206] Upgrade
gradle/actionsto6.3.0. - [#4207] Upgrade
gradleto9.7.0.
File: wiki/the-basics/building.mdx
title: Building sidebar_position: 3
The build option can be invoked either from b or build like shown below
$ 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:::info
In order to run a rebuilt application, you must resign it.
Android documentation can help with this.
:::
File: wiki/the-basics/decoding.mdx
title: Decoding sidebar_position: 2
The decode option can be invoked either from d or decode like shown below.
$ 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 folderFile: wiki/the-basics/frameworks.mdx
title: Frameworks sidebar_position: 4
Frameworks can be installed either from if or install-framework, additionally with two paramaters.
-p, --frame-path <directory>- Store framework files into the<dir>.-t, --tag <tag>- Tag frameworks using<dir>as the tag.
This allows for finer control over how the files are stored and named.
$ 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.apkFile: wiki/the-basics/intro.mdx
title: Introduction sidebar_position: 1
First lets take a lesson into apk files. Apks are nothing more than a zip file containing resources and assembled java code.
If you were to simply unzip an apk like so, you would be left with files such as classes.dex and resources.arsc.
$ 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.arscHowever, at this point you have simply inflated compiled sources. If you tried to view AndroidManifest.xml. You'd be left viewing a malformed file.
Obviously, editing or viewing a compiled file is next to impossible. That is where Apktool comes into play.
$ 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...Viewing AndroidManifest.xml again results in something much more human readable
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android" package="brut.apktool.testapp"
platformBuildVersionCode="21" platformBuildVersionName="APKTOOL" />In addition to XMLs, resources such as 9 patch images, layouts, strings, and much more are correctly decoded to source form.