How To Decompile And Compile Android APK's On A Mac Using Apktool

Most instructions around on the web for decompiling and compiling Android APK files are for Windows PC users, but what about Mac users who have a native command line yo?

The steps are pretty much the same, except you need to do one more thing.

Requirements
– A Mac
– An internet connection
– Java SDK and JRE
– Android SDK
– Apktool

Step 1 – Install Java SDK and JRE

You can download Java from this link. The Apktool will mostly use the SDK libraries, but JRE will be required for some tasks, so we install both just in case.

Step 2 – Install the Android SDK

Working with APK files, naturally, we will require the Android SDK. You can download the Android SDK from this link.

Step 3 – Download the Apktool

Download the Android Apktool from this link. This is a Java application that we will run from the command line and includes everything necessary to decompile and compile Android APK files.

Step 4 – Root permissions

These instructions will apply to all macOS versions but may differ slightly depending on the version. Root permission is required for the breadth of tasks we will be performing and the permissions the Apktool requires to compile and decompile.

  • Open “System Preferences”
  • Click “Users & Groups”
  • Click “Login Options” shown in the left-hand pane at the bottom
  • Click the padlock at the bottom left to make changes
  • Click “Join” next to the text “Network Account Server”
  • Click “Open Directory Utility” in the dialogue that pops up
  • In the popup, click the padlock in the bottom left again to make changes
  • In the top menu bar of the screen, click “Edit” and then click “Enable Root Mode” if you haven’t already set a password, it will ask you to do so.

Step 5 – Open up a terminal window

Now that we’ve got our stuff in order, let’s open up a terminal window and prepare for compiling and decompiling.

Elevate the current terminal to super user status by typing:

su

(Enter your root password when asked)

Decompiling using Apktool

Now that everything is installed and root permissions, let’s decompile an APK file.

apktool d someapk.apk

Compiling an APK from a previously decompiled APK

If you want to compile an APK you have decompiled, it looks the same as above, with exception of one argument.

Please note you do not need to use quotation marks below when referencing the folder (as with the previous example).

apktool b "decompiled APK folder"

This post does not cover signing the APK file, which must be done before a compiled app will work. This guide assumes you already know how to use Apktool and aware of the fact you need to sign the app, a simple Google search will yield instructions for signing your compiled APK file.