How to set up smartphones and PCs. Informational portal

Download system file editor apk. How to edit apk files on computer

In this article, you will learn what an android application consists of, how to open an APK file and with what programs.

What is an APK file?

APK is the format of the Android operating system used for archive executable application files, and the name of the file itself can be anything, but the extension should only look like .apk. APK analogues in other operating systems are .msi in Windows, .sis in Symbian, .rpm or .deb in Linux.

Let's see what's inside
In fact, .apk is a ZIP archive, so you can look at the internal device using any file manager or archiver, such as WinRAR or the X-plore mobile application.





At the same time, it is worth remembering that you get only visual access to internal resources, editing options are extremely limited.
Consider the structure
Inside the .apk we see a number of files and folders, let's find out what they are for:
  • AndroidManifest.xml is a kind of "passport" of the application from which you can find out all the main points, requirements, version, permissions, and more.
  • META-INF this file contains metadata, i.e. data about data, checksums, data paths, resource paths and checksums, certificates. You can open this file with any text editor, but Notepad++ is recommended.
  • The res folder contains all program resources, graphic resources such as icons, pictures, text, GUI elements. You can also easily access the folder.
  • classes.dex - the direct program code of the application executed by the Dalvik VM virtual machine, you can see what is inside this file only by decompiling the .apk, we will talk about this in other articles. resources.arsc - compiled XML file, this file contains data about all resources involved in the program.
  • lib - a folder with native libraries, the resources of which can be accessed only when using specialized programs. Also in the APK, there may be such files and folders as com, org, udk, but not always.

Now let's look at the internal structure in more detail, for this we need a decompiler program, Java and an APK file. The main tool for disassembling .apk is Apktool, but this program only works from the line, which is not very convenient. For faster and more convenient parsing, you can use APKing, it's still the same Apktool, but with the ability to work from the context menu.
And so we install APKing as any application for Windows and by selecting .apk we click on it with the right mouse button and at the same time Shift, after which we will see the following:


And we select the necessary action, for example, decompile completely, then the program will complete the operation and create a folder with the same name.


By opening the folder, we will have access to all the resources of the APK file.


Now all text files can be edited, while observing the basic rules, you can use the popular Notepad ++ program, for example, consider AndroidManifest.xml

Programs for the Android platform are the only file with the apk extension, which is very convenient. In fact, installing any program on a smartphone or tablet comes down to simply copying it to your gadget. What is an apk file and how can you see what's inside?

What is an APK file?

The abbreviation APK stands for Android Package Kit, an executable package of files for Android applications. This is an archive containing compiled and ready-to-run codes and other resources. apk files are stored on Internet sites like Google Play, from where they can be downloaded and installed on your gadget. They are not encrypted.

Its structure is prepared by the developer to run in the Dalvik or ART virtual machine environment. These machines are built into the Android OS, and they run all the applications that are on your device.

The apk file itself is a regular archive that you can open with any archiver in the Windows environment. For example, WinRAR, or a file manager that opens ZIP archives. Let's see what's inside there.

  • An executable file with the dex extension (the name can be anything), which is just the program code.
  • Next to it is resources.arsc, this is a registry of resources that the program should use. This is an XML structure.
  • AndroidManifest.xml is a mandatory file for any program, a manifest that contains the main information about it. Here, for example, the version of the program, the required version of Android, information about the developer, the required screen resolutions, and so on can be recorded.
  • The res directory contains the internal resources that the program needs to run. All pictures, icons, icons, maps, and so on can be here.
  • The lib directory is the native libraries for the program to work, for example, C++ code. This directory may be missing if libraries are not used.
  • The assets directory is additional resources for the application, it may also sometimes be missing. Which resources should be used is described in the resources.arsc file.
  • Directory META-INF - program metadata. For example, the MANIFEST.MF file, which may contain paths to data and their checksums. RSA certificate files, Manifest-Version information, and similar service information can be stored here.

Overview of Popular APK File Editors

As already mentioned, you can unpack the apk file with any ZIP archiver. After that, you can view the resources stored there.

There will be no problems with images at all, they can be opened in any appropriate program. The XML format can be opened with any text editor such as Notepad++. If you know how this format works, then they can already be edited. But for compiled executable files, you will have to use special tools.

Eclipse Editor. This is a full-fledged cross-platform environment for a programmer. You can develop in any modern languages ​​and prepare executable files, including for Android. The environment can be flexibly configured using numerous plugins.

Android SDK. As the name implies, this is a specialized tool for developing mobile programs specifically for Android. With it, you can easily decompile the executable files of someone else's application, or write your own from scratch. It differs in that it optionally connects various modules for debugging and testing your code, for testing programs for compatibility with different gadgets, and so on.

APK downloader. This is a plugin for the Chrome browser that makes it very easy to download apk programs from any sites and view their structure. To do this, you can even be not registered on Google Play.

APK Editor. An editor that allows you to work with resources inside apk packages. Not as powerful as Eclipse, but does a lot of simple things. For example, you can remove ad blocks from the program, Russify the interface, replace icons or textures with your own, and much more.

Apk editor pro, which you can download for android on our website, will allow you to hack / change the contents of the files of any application for mobile devices and customize it to your liking.

Peculiarities

The program is a professional utility that in the hands of advanced users can become a powerful tool for editing applications for android. The functionality practically does not differ from similar software for personal computers.

What can this utility do?

  1. Change (translate) the names of other applications.
  2. Change architecture layouts, colors, graphic settings templates (eg icon size).
  3. Change sound design, media files.
  4. Remove ads.
  5. Bypass paid content blocking.
  6. Move the application from the internal memory of the device to the SD card.
  7. Change resolution and more.

To understand how to use the utility, you need to download apk editor pro and go to the menu. Then select either an already installed application on android, or its apk file. After that, by default, data will be opened that the user can change:

  • resource editing;
  • file replacement;
  • general editing;
  • data editing.

The program will prompt you to install the modified version. This does not work in all cases, so the old version must be manually uninstalled and the new one installed. After uninstallation, you should select the apk editor folder (for convenience, you can use ES Explorer) among the programs on android and find the modified application file, install it on the device.

The program has a user-friendly interface. Navigation is quite simple, but the user needs to have a basic knowledge of English to get it right.

Advantages and disadvantages

  1. The program offers the user a wide range of options for customizing applications.
  2. There is a Help section in the menu, which simply and in detail describes a large amount of the editor's program features. Therefore, users who are far from programming will not have to look for examples and editing instructions on third-party resources.
  3. You can download the program for free from our website.

Using this utility requires some skills and knowledge. In the hands of an inexperienced user, editing can lead to violations of the integrity of the file system, which will eventually lead to application crashes. In the menu in the Help item there are examples of conversion with pictures and tips for the correct use of apk editor pro on android. Therefore, if you want to deal with this program, just follow the instructions.

The editor is a rather useful tool for those who are faced with an inconvenient application interface (no Russian language, constant advertising, banners, etc.). If you have already used this program, share your impressions below in the comments.

Sometimes some applications on Android do not suit the user for some reason. An example is annoying ads. And it happens that way - everyone is good at the program, but only the translation in it is either crooked, or completely absent. Or, for example, the program is trial, but there is no way to get the full version. How to change the situation?

Introduction

In this article, we will talk about how to disassemble an APK with an application, look at its internal structure, disassemble and decompile the bytecode, and also try to make several changes to applications that can bring us this or that benefit.

To do all this on your own, you will need at least a basic knowledge of the Java language, in which Android applications are written, and the XML language, which is used everywhere in Android - from describing the application itself and its access rights to storing strings that will be displayed on the screen. You will also need the ability to handle specialized console software.

So, what is the APK package in which absolutely all software for Android is distributed?

Application decompilation

In the article, we only worked with disassembled application code, however, if you make more serious changes to large applications, it will be much more difficult to understand the smali code. Fortunately, we can decompile the dex code into Java code, which, although not original and not compilable back, is much easier to read and understand the logic of the application. To do this, we need two tools:

  • dex2jar - translator of Dalvik bytecode to JVM bytecode, based on which we can get Java code;
  • jd-gui is a decompiler itself that allows you to get readable Java code from JVM bytecode. Alternatively, you can use Jad (www.varanecas.com/jad); although it is quite old, in some cases it generates more readable code than Jd-gui.

They should be used like this. First, we launch dex2jar, specifying the path to the apk package as an argument:

%dex2jar.sh mail.apk

As a result, the mail.jar Java package will appear in the current directory, which can already be opened in jd-gui to view the Java code.

Arranging APK packages and getting them

An Android application package is essentially a regular ZIP file that does not require any special tools to view the contents and unpack. It is enough to have an archiver - 7zip for Windows or console unzip in Linux. But that's about the wrapper. What's inside? Inside, we generally have the following structure:

  • META-INF/- contains a digital certificate of the application, certifying its creator, and checksums of the package files;
  • res/ - various resources that the application uses in its work, such as images, a declarative description of the interface, and other data;
  • AndroidManifest.xml- description of the application. This includes, for example, the list of required permissions, the required version of Android, and the required screen resolution;
  • classes.dex- compiled application bytecode for the Dalvik virtual machine;
  • resources.arsc- also resources, but of a different kind - in particular, strings (yes, this file can be used for Russification!).

The listed files and directories are, if not in all, then, perhaps, in the vast majority of APKs. However, there are a few more less common files/directories worth mentioning:

  • assets- analogue of resources. The main difference is that to access a resource, you need to know its identifier, while the list of assets can be obtained dynamically using the AssetManager.list() method in the application code;
  • lib- native Linux libraries written with the help of NDK (Native Development Kit).

This directory is used by game manufacturers, where they put their game engine written in C/C++, as well as by creators of high-performance applications (for example, Google Chrome). Understood the device. But how to get the package file of the application of interest? Since it is not possible to get APK files from the device without rooting (they are in the / data / app directory), and rooting is not always advisable, there are at least three ways to get the application file to your computer:

  • APK Downloader extension for Chrome;
  • Real APK Leecher app;
  • various file hosting and warezniki.

Which one to use is a matter of taste; we prefer to use separate applications, so we will describe the use of Real APK Leecher, especially since it is written in Java and, accordingly, it will work even in Windows, even in nix.

After starting the program, you need to fill in three fields: Email, Password and Device ID - and select a language. The first two are the e-mail and password of your Google account that you use on the device. The third is the device ID, and you can get it by dialing the code on the dialer # #8255## and then finding the line Device ID. When filling out, you need to enter only the ID without the android- prefix.

After filling in and saving, the message “Error while connecting to server” often pops up. It has nothing to do with Google Play, so feel free to ignore it and look for packages that interest you.

Review and modification

Let's say you found a package you are interested in, downloaded it, unpacked it ... and when you tried to view some XML file, you were surprised to find that the file is not a text file. How to decompile it and how to work with packages in general? Is it really necessary to install the SDK? No, you don't need to install the SDK. In fact, for all the steps to unpack, modify and package APK packages, the following tools are needed:

  • ZIP archiver for unpacking and packing;
  • smali- assembler/disassembler of Dalvik virtual machine bytecode (code.google.com/p/smali);
  • aapt- a tool for packing resources (by default, resources are stored in binary form to optimize application performance). Included with the Android SDK, but can be obtained separately;
  • Signer- a tool for digitally signing a modified package (bit.ly/Rmrv4M).

You can use all these tools separately, but this is inconvenient, so it is better to use higher-level software built on their basis. If you're on Linux or Mac OS X, there's a tool called apktool . It allows you to unpack resources into their original form (including binary XML and arsc files), rebuild the package with modified resources, but it does not know how to sign packages, so you will have to run the signer utility manually. Despite the fact that the utility is written in Java, its installation is rather non-standard. First you need to get the jar file itself:

$ cd /tmp $ wget http://bit.ly/WC3OCz $ tar -xjf apktool1.5.1.tar.bz2

$ wget http://bit.ly/WRjEc7 $ tar -xjf apktool-install-linux-r05-ibot.tar.bz2

$ mv apktool.jar ~/bin $ mv apktool-install-linux-r05-ibot/* ~/bin $ export PATH=~/bin:$PATH

If you work on Windows, then there is an excellent tool for it called Virtual Ten Studio , which also accumulates all these tools (including apktool itself), but instead of a CLI interface, it provides the user with an intuitive graphical interface with which to perform operations for unpacking, disassembling and decompiling in a few clicks. This tool is Donation-ware, that is, windows sometimes appear with a proposal to obtain a license, but this, in the end, can be tolerated. It makes no sense to describe it, because you can understand the interface in a few minutes. But apktool, due to its console nature, should be discussed in more detail.


Consider apktool options. In short, there are three main commands: d (decode), b (build) and if (install framework). If everything is clear with the first two commands, then what does the third one, the conditional operator, do? It unpacks the specified UI framework, which is needed when you dissect a system package.

Consider the most interesting options of the first command:

  • -s- do not disassemble dex files;
  • -r- do not unpack resources;
  • -b- do not insert debugging information into the results of disassembling the dex file;
  • --frame-path- use the specified UI framework instead of the built-in apktool. Now consider a couple of options for the b command:
  • -f- forced assembly without checking changes;
  • -a- specify the path to aapt (the tool for building the APK archive) if for some reason you want to use it from another source.

Using apktool is very simple, all you need to do is specify one of the commands and the path to the APK, for example:

$ apktool d mail.apk

After that, all the extracted and disassembled package files will appear in the mail directory.

Preparation. Disable ads

Theory is, of course, good, but why is it needed if we do not know what to do with the unpacked package? Let's try to apply the theory for our own benefit, namely, we modify some software so that it does not show us ads. For example, let it be Virtual Torch - a virtual torch. For us, this software is perfect, because it is full of annoying ads and is simple enough not to get lost in the wilds of code.


So, using one of the above methods, download the application from the market. If you decide to use Virtuous Ten Studio, just open the APK file in the application and unpack it, for which create a project (File -> New project), then select Import File from the context menu of the project. If your choice fell on apktool, then it is enough to execute one command:

$ apktool d com.kauf.particle.virtualtorch.apk

After that, a file tree will appear in the com.kauf.particle.virtualtorch directory, similar to the one described in the previous section, but with an additional smali directory instead of dex files and an apktool.yml file. The first one contains the disassembled code of the application's executable dex file, the second one contains service information needed by apktool to assemble the package back.

The first place we need to look is, of course, AndroidManifest.xml. And here we immediately meet the following line:

It is easy to guess that she is responsible for granting the application permissions to use the Internet connection. In fact, if we just want to get rid of ads, it will most likely be enough for us to ban the application from the Internet. Let's try to do it. Delete the specified line and try to compile the software using apktool:

$ apktool b com.kauf.particle.virtualtorch

The resulting APK file will appear in the com.kauf.particle.virtualtorch/build/ directory. However, it cannot be installed because it does not have a digital signature and file checksums (it simply does not have a META-INF/ directory). We have to sign the package with the apk-signer utility. Launched. The interface consists of two tabs - on the first (Key Generator) we create keys, on the second (APK Signer) we sign. To create our private key, fill in the following fields:

  • Target File- keystore output file; it usually stores one pair of keys;
  • Password And Confirm- password for storage;
  • Alias- name of the key in the repository;
  • Alias ​​password And Confirm- secret key password;
  • Validity- Validity period (in years). The default value is optimal.

The remaining fields, in general, are optional - but you must fill in at least one.


WARNING

To sign an application with apk-signer, you must install the Android SDK and specify the full path to it in the application settings.

All information is provided for informational purposes only. Neither the editors nor the author are responsible for any possible harm caused by the materials of this article.

Now you can sign the APK with this key. On the APK Signer tab, select the newly generated file, enter the password, key alias and password for it, then find the APK file and boldly click the "Sign" button. If everything goes well, the package will be signed.

INFO

Since we signed the package with our own key, it will conflict with the original application, which means that when we try to update the software through the market, we will get an error.

Only third-party software needs a digital signature, so if you are modifying system applications that are installed by copying them to the /system/app/ directory, then you do not need to sign them.

After that, we drop the package on the smartphone, install and run. Voila, the ad is gone! Instead, however, a message appeared that we do not have the Internet or do not have the appropriate permissions. In theory, this could be enough, but the message looks annoying, and, to be honest, we just got lucky with a stupid application. A well-written software will most likely clarify its credentials or check for an Internet connection and otherwise simply refuse to start. How to be in this case? Of course, edit the code.

Typically, application authors create special classes for displaying advertisements and call methods of these classes during the launch of the application or one of its "activities" (in simple terms, application screens). Let's try to find these classes. We go to the smali directory, then com (in org there is only the open graphic library cocos2d), then kauf (exactly there, because this is the name of the developer and all his code is there) - and here it is, the marketing directory. Inside we find a bunch of files with the smali extension. These are classes, and the most notable of them is the Ad.smali class, by the name of which it is easy to guess that it displays ads.

We could change the logic of its work, but it would be much easier to stupidly remove calls to any of its methods from the application itself. Therefore, we exit the marketing directory and go to the neighboring particle directory, and then to virtualtorch. The MainActivity.smali file deserves special attention here. This is a standard Android class that is generated by the Android SDK and set as the entry point to the application (analogous to the main function in C). Open the file for editing.

Inside is the smali code (local assembler). It is rather confusing and difficult to read due to its low-level nature, so we will not study it, but simply find all mentions of the Ad class in the code and comment them out. We drive in the string "Ad" in the search and get to line 25:

Field private ad:Lcom/kauf/marketing/Ad;

Here, a field ad is created to store an object of class Ad. We comment by setting the ### sign in front of the line. We continue the search. Line 423:

New-instance v3, Lcom/kauf/marketing/Ad;

This is where the object is created. We comment. We continue the search and find in lines 433, 435, 466, 468, 738, 740, 800 and 802 calls to the methods of the Ad class. We comment. Look like that's it. We save. Now the package needs to be assembled back and checked for its performance and the presence of advertising. For the purity of the experiment, we return the line removed from AndroidManifest.xml, collect the package, sign it and install it.

Our guinea pig. Visible advertising

Op-pa! Advertising disappeared only while the application was running, but remained in the main menu, which we see when we launch the software. So, wait, but the entry point is the MainActivity class, and the advertisement disappeared while the application was running, but remained in the main menu, so the entry point is different? To reveal the true entry point, we reopen the AndroidManifest.xml file. And yes, it contains the following lines:

They tell us (and more importantly, the android) that the activity named Start should be launched in response to the generation of the android.intent.action.MAIN intent (event) from the android.intent.category.LAUNCHER category. This event is generated when you tap on the application icon in the launcher, so it defines the entry point, namely the Start class. Most likely, the programmer first wrote an application without a main menu, the entry point to which was the standard MainActivity class, and then added a new window (activity) containing the menu and described in the Start class, and manually made it an entry point.

We open the file Start.smali and again look for the line "Ad", we find in lines 153 and 155 the mention of the FirstAd class. It is also in the source code and, judging by the name, it is responsible for displaying ads on the main screen. We look further, there is a creation of an instance of the FirstAd class and an intent, according to the context related to this instance, and then the label cond_10, the conditional transition to which is carried out exactly before creating an instance of the class:

If-ne p1, v0, :cond_10 .line 74 new-instance v0, Landroid/content/Intent; ... :cond_10

Most likely, the program somehow randomly calculates whether it is necessary to show ads on the main screen, and if not, jumps directly to cond_10. Ok, let's simplify her task and replace the conditional transition with an unconditional one:

#if-ne p1, v0, :cond_10 goto:cond_10

There are no more mentions of FirstAd in the code, so we close the file and re-assemble our virtual torch using apktool. Copy to smartphone, install, run. Voila, all ads are gone, congratulations to all of us.

Results

This article is just a brief introduction to the methods of opening and modifying Android applications. Many issues remained behind the scenes, such as removing protection, parsing obfuscated code, translating and replacing application resources, as well as modifying applications written using the Android NDK. However, having basic knowledge, understanding all this is only a matter of time.

Editing Android system applications is most often carried out when the user of a smartphone, tablet or other device controlled by this operating system ceases to satisfy the current appearance of the programs installed in the device by the manufacturer or seller. Another reason may be the need to make not only changes regarding the graphic design of Android applications, but also affecting the location of various elements and the performance of basic functions.

In order to make changes to the code, elementary programming skills are required in almost any language (preferably Java and C ++). To replace graphics, direct hands and the ability to work in a graphics editor will do.

First of all, you should decide whether you just need to replace the graphics in Android applications or whether you need to change the arrangement of elements in the system and make deeper changes in the code. Further steps depend on this, which involve either working with the application as an archive, or its complete disassembly and editing.

Changing graphics in Android system applications

In order to simply replace or modify the original graphics (change button colors, redraw pictures, etc.), it is enough to have a standard WinRAR archiver on your computer. At the same time, the user must have “root” rights on the device (an analogue of the administrator account on Windows), and it is also desirable to have an alternative recovery (CWM) and a root explorer (to access the Android file system directly in the device itself).

First of all, you need to enable USB debugging in the device, then connect it to the computer using a USB cable and install the necessary drivers. Usually they are located on a virtual disk that appears when connected to a computer.

Then you also need to download the ADB plugin for the file manager on the Internet. This plugin allows you to see the entire Android system as a connected drive with folders. All system applications are located at /system/app and /system/framework. Having found the desired application, simply copy it to your computer. If the plugin is not installed, you can use the root explorer to copy the application with the apk extension to a removable SD card, and then from it to your computer.

After copying the desired application, you can start editing graphics. By the way, all pictures in Android applications are saved in png format, which can be easily opened by any graphics editor. When you open the application file with WinRAR, you can see a number of folders. We will only be interested in the res folder, inside which, in turn, a lot of different folders will be found. Of these, only those that have the word "drawable" in their name are needed.

Now let's remember our device type and its screen resolution. If this is a smartphone, and the resolution is 240x320, then we will be mainly interested in the drawable and drawable-ldpi folders. If the resolution is 320x480 - the drawable and drawable-mdpi folders, respectively, and for the resolution 480x800 - the drawable and drawable-hdpi folders. In addition to them, there are usually also folders with the word "land" in their names - these are graphics for portrait mode, i.e. when the device is tilted.

If you have a tablet in your hands, then we will only be interested in the drawable and drawable-mdpi folders at any screen resolution.

By copying the selected folders to your computer, you can replace or recolor the original images with the desired and pleasing to the eye. You should pay special attention to pictures with a resolution of 9.png. The fact is that along the perimeter of such an image there is a special frame one pixel wide with special marks, the violation of the integrity of which will lead to a failure of the application. Therefore, extra care must be taken when editing such files.

After editing the folder, you need to upload it back to the archive, which is the application itself with the apk extension. In this case, it is necessary to select the “no compression” option in WinRAR.

The corrected application is downloaded back to the device either using the root explorer (first the file is copied to the SD card, and from it to the device), or after exiting the recovery - immediately from the computer to the / system / app or / system / framework folder . Next, you must set the file permissions using the appropriate options in the root explorer or the ADB plugin. They must be in 644 format. After rebooting the device, you can see the result of the updated application.

Editing the source code of system applications

A little more effort is needed to edit the source code of system applications. In order to disassemble and build the application after making changes to it, you will need to perform a few of the following steps.

1) Install the required software package on your computer in their latest versions: Java SE Runtime Environment and Android SDK Windows (programs for working with applications and their components), APKtool or APKManager or Firmware_tool (one of three programs for disassembling and decompiling system applications), NotePad++ editor (for making changes to the source code of Android system applications).

2) Enable USB debugging in the device, connect it to the computer using a USB cable, install the necessary drivers to work with the device.

3) Using one of the above programs for working with application code, you need to extract the folder / system / framework (completely) from the phone to the appropriate folder of the program and system applications from the / system / app folder. For example, for the Firmware_tool program, files from the phone must be copied to the C: Firmwaretoolfw_project1_source2_system.img_unpacked folder in the appropriate subfolders (applications to the app folder, files from the framework to the framework folder). When using both this and other programs, be sure to read the instructions for them.

4) Install the "reference framework", i.e. a set of rules in accordance with which decompilation (i.e. code disassembly) and compilation (i.e. code assembly) of applications will be carried out.

This completes the preparation for working with system applications.

Unloading applications from the device and loading them back is carried out similarly to the procedure described in the section “Changing graphics in Android system applications”.

Editing Android application code is usually done using the NotePad ++ editor - one of the most convenient text editors that has the option of highlighting the syntax of the selected programming language. As a rule, when editing, you can also change the graphics along the way using the selected graphics editor.

Upon completion of editing, the modified application is loaded back into the device, and the device itself needs to be rebooted. More advanced editors for debugging applications before downloading them to the device use various emulators, for example, Eclipse from Google.

Top Related Articles