Decompiling an APK file on Android

APK file for Android Each operating system has its own file types, which are executable programs. So, on Windows they have the '.exe' extension, on MacOS their function is more or less hung on the '.pkg' container files, and on Android – '.apk'.

This extension stands for Android Package and means that the file contains all the components necessary to run the application. They are distributed through the Play Store or its free counterparts like F-droid.

In addition, on various sites dedicated to mobile devices, for example, or XDA, such files can be downloaded independently. Installing the latter may require additional actions from the user, such as activating the right to deploy software components obtained from unknown sources on the device in the phone settings.

Decompilation of applications and its functions

One of the programming languages ​​that is used when writing programs for the OS Android is Java. As a rule, beginners and people who are accustomed to its tools write programs on it. Large developers use other languages ​​that give more freedom to use third-party libraries or software components.

In order for the written code to turn into a working application, it must be compiled with the compiler built into the SDK (Software Development Kit). The reverse process, when the program code is obtained from the finished APK file, is called decompilation.

Why might you need to decompile such files? There are several situations in which this comes in handy:

  1. The user does not have enough provided functionality and he has enough knowledge and experience to make changes to the finished code.
  2. See how a certain component of the program works and gain the necessary experience in its implementation when creating your own product.
  3. Determine if the application is using any parts of the malicious code.

As you can see, all these tasks require some experience with programming languages ​​and Android SDK. But at the same time, on the Internet there are many instructions that beginners can also do, which makes the reverse compilation process useful for them. You just need to follow the instructions.

to the content

APK decompilers

There are three types of this type of software – installed on a computer, on the user's phone and cloud-based. The first and second have a wider range of functions. The latter are attractive in that they do not use hardware performance and work directly from the browser. The disadvantage of cloud services is the limited support for third-party modules and add-ons, the user is left with the set of functions that the owner of the service provides.

It is worth noting that the developers build in protection against such actions. This is called obfuscation and is done through special services. At the same time, the structure and functionality of the fully assembled program is not violated, but after decompilation, the user receives incoherent pieces of machine code that make detailed analysis impossible.

to the content

Best PC Software

This is one of the most feature-rich utilities – APK Easy Tool . It works with several types of files and is capable of unpacking files at any stage of development. The main window contains several tabs that contain all the utility's features:

  • Main is the starting point for working with programs. Here you can set a folder to receive all source files by reverse engineering, decompile and compile them, sign and modify signatures after making changes. At the bottom of the tab for all processes, all service information about the toolkit versions is displayed. APK Easy Tool
  • Framework – a tab for connecting additional modules and frameworks that can help in the process of unpacking or packaging the finished product. It supports installation of the framework in APK format and assigning a separate folder for each version or variety. Framework
  • Smali / backsmali – respectively, a compiler and decompiler of files written in decimal format. At the time of this writing, the function is in beta, but works without major bugs. The functionality is quite primitive, there are only two buttons – 'Compile' and 'Decompile'. You can select folders for source code or the target storage destination for the recompiled result. Compilation and decompilation
  • Log output – a tab useful for debugging processes, contains all the logs of each of the started processes. Analysis of logs
  • Options – allows you to flexibly configure the program to perform all tasks. There are options for connecting different versions of Apktool and APK Signer utility to ensure maximum compatibility with earlier versions Android. There are 4 own tabs with different parameters. Settings
  • FAQ – frequently asked questions, built-in instructions to help users overcome the most common mistakes in their work. FAQ
  • About – version information and developer contacts with details for voluntary support. About the program, donations

The application works on versions Windows starting from Vista and does not support the Russian interface. In terms of functionality, it is quite suitable for both a beginner who will deal with it with the help of instructions and video manuals, and an experienced application developer.

to the content

Decompilation on a mobile device

When it is not possible to debug an application on a computer, and this must be done, programs for the phone come to the rescue. These are also APK files, which are not too rich in settings, but reliable Java decompilers. The simplest, but at the same time useful of such utilities is Show Java – A Java Decompiler.

The principle of operation is very simple:

  1. The initial window is quite minimalistic – a greeting and a '+' button to start work with. Show Java - A Java Decompiler
  2. By clicking on the '+', the user must choose where to download the program for decompilation – from the internal memory or choose from those already installed. Method selection
  3. If the first item is selected, the next step is to navigate to the folder with APK files and select one of them. Then you need to confirm this action by clicking on Select. Folder with apk files
  4. After that, a decompiler is selected to be used in the process. Decompiler selection
  5. And then a window with the progress of the operation is displayed. If it succeeds, the user sees all the files necessary for the application to function and its source code. If not, an error window is displayed. Decompilation process

Among the shortcomings – poor decoding of files that were subject to obfuscation. As for the rest, the set of features here is practically indistinguishable from the desktop counterparts.

to the content

Cloud service provides all the capabilities to parse APK files into their component parts. In addition to a good online decompiler, there is also a network version of APKTools, which is useful if the necessary devices are not at hand or the user does not want to waste time installing applications.

The principle of operation is simple:

  1. You need to open your browser and go to Cloud service for decompilation
  2. Select file from Explorer and click 'Upload and Decompile' button.
  3. The decompilation process looks like this here (the red line – progress, indicating a specific process, is duplicated at the bottom of the screen in the area with the heading Decompilation Results). Decompilation process
  4. After the end of the process, the status changes to a window of this type, in which there is an opportunity to download the received files. Download received files
  5. The file preview is located at the bottom of the page and allows you to assess the degree of success after completion. The file structure is saved in the form in which the archive will be downloaded, with the entire tree of directories and subdirectories. If the content of at least one of them is difficult to read, then the obfuscation could not be bypassed. Successful decompilation of apk file
  6. All files are packed into an archive and look like this. Received archive

Once unpacked, you can do whatever you want with them. The cloud service provides unlimited access, although it displays a lot of advertisements in the course of its work. The JaDX decompiler is used for functioning, which may not satisfy the requirements of some projects. The link to the project can be published on one of the social networks. There is no import on github, which is also not very convenient for the end developer who does not have the necessary tools at hand.

Rate article
Everything for Android and not only | Tips, instructions, root, news and app reviews.
Add a comment