How to remove an apk. How to extract the APK file of the application? Google account name and device ID

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

Introduction

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

To do all this on your own, you 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 the strings that will be displayed on the screen. You will also need to be able to handle specialized console software.

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

Decompiling applications

In this article, we worked only 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 dex the dex code into Java code that, although not original and not compiled 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 into JVM bytecode, on the basis of which we can get code in Java;
  • jd-gui is the decompiler itself, which allows you to get readable Java code from the JVM bytecode. Alternatively, you can use Jad (www.varaneckas.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 run 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.

APK package device and getting them

Package android apps, in fact, is a regular ZIP file, for viewing the contents and unpacking which no special tools not required. It is enough to have an archiver - 7zip for Windows or console unzip for 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, for example, images, a declarative description of the interface, and other data;
  • AndroidManifest.xml - application description. This includes, for example, a list of required permissions, required android version and the required screen resolution;
  • classes.dex - compiled application bytecode for virtual machine Dalvik;
  • 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 not-so-common files / directories worth mentioning:

  • assets - analogue of resources. The main difference is that to access an asset, 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 NDK (Native Development Kit).

This directory is used by game manufacturers, who put their game engine written in C / C ++, as well as developers of high-performance applications (for example, Google chrome). The device was sorted out. But how do you get the actual package file of the application of interest? Since it is not possible to pick up APK files from the device without root (they are in the / data / app directory), and root is not always advisable, there are at least three ways to get the application file to the computer:

  • aPK Downloader extension for Chrome;
  • real APK Leecher application;
  • various file sharing 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, will work even in Windows, even in nicks.

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 your device. The third is the device identifier, and you can get it by dialing the code on the dialer # #8255## and then finding the Device ID string. When filling in, you only need to enter the ID without the android- prefix.

After filling out and saving, the message “ Error while connecting to server ". It has nothing to do with Google play, so feel free to ignore it and look for the packages you are interested in.

View and modify

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

  • zIP archiver for unpacking and packing;
  • smali - assembler / disassembler of bytecode of the Dalvik virtual machine (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 - tool for digital signature modified package (bit.ly/Rmrv4M).

You can use all these tools separately, but this is inconvenient, so it is better to use a higher-level software built on their basis. If you work on Linux or Mac OS X, there is a tool called apktool. It allows you to unpack resources in their original form (including binary XML and arsc files), rebuild a package with changed resources, but it cannot 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 should 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 \u003d ~ / bin: $ PATH

If you work in 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 the CLI interface provides the user with an intuitive graphical interface with which you can perform operations on unpacking, disassembling and decompiling in a few clicks. This tool is Donation-ware, that is, sometimes there are windows offering 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.


Let's take a look at the 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 teams, then what does the third one do, conditional operator? It unpacks the specified UI framework, which is needed in cases where you dissect any system package.

Let's consider the most interesting options of the first command:

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

Using apktool is very simple, you just need to 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.

Dissection. 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 to our advantage, namely, 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 packed full of annoying ads and also simple enough not to get lost in the jungle 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 -\u003e New project), then in context menu select Import File. If your choice fell on apktool, then just execute one command:

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

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

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

As you might guess, it is responsible for granting the application permission to use the Internet connection. In fact, if we just want to get rid of ads, we will most likely need to disable the Internet for the application. Let's try to do this. We delete the specified line and try to build 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, you will not be able to install it, since it does not have a digital signature and file checksums (it simply does not have the META-INF / directory). We need to sign the package using 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 - the output file of the keystore; it usually contains one key pair;
  • Password and Confirm - password for storage;
  • Alias - the name of the key in the repository;
  • Alias \u200b\u200bpassword and Confirm - secret key password;
  • Validity - validity period (in years). The default is optimal.

The rest of the fields are generally optional - but at least one must be filled in.


WARNING

To sign an application using 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 editorial board nor the author is 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 to it, then find the APK file and boldly press the "Sign" button. If all 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 receive an error.

A digital signature is only required for third-party software, so if you are modifying system applicationsthat are installed by copying to the / system / app / directory, you do not need to sign them.

After that, we drop the package onto the smartphone, install and launch it. Voila, ads are 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 were just lucky with a dumb app. A normally written software will most likely clarify its authority 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 application launch or one of its "activities" (to put it simply, application screens). Let's try to find these classes. We go to the smali directory, then com (org contains only the open graphics 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 what exactly it displays ads.

We could change the logic of its operation, but it would be much easier to remove calls to any of its methods from the application itself. Therefore, we exit the marketing directory and go to the adjacent particle directory, and then to virtualtorch. The MainActivity.smali file deserves special attention here. This is a standard Android class that is created 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 quite confusing and difficult to read due to its low-level nature, so we will not study it, but simply find all references to the Ad class in the code and comment them out. We drive in the line "Ad" in the search and find ourselves on line 25:

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

This creates an ad field to hold an object of class Ad. We comment by placing the ### sign in front of the line. We continue to search. Line 423:

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

This is where the object is created. Commenting. We continue searching and find in lines 433, 435, 466, 468, 738, 740, 800 and 802 calls to methods of the Ad class. Commenting. Look like that's it. We save. Now you need to put the package back together and check its performance and the presence of ads. For the purity of the experiment, we return the string deleted from AndroidManifest.xml, collect the package, sign and install.

Our guinea pig. Advertising visible

Oops! The advertisement 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 ads disappeared while the application was running, but remained in the main menu, so the entry point is different? To identify the true entry point, reopen the AndroidManifest.xml file. And yes, it has the following lines:

They tell us (and more importantly, the android) that an activity named Start should be launched in response to the generation of an intent (event) android.intent.action.MAIN from the android.intent.category.LAUNCHER category. This event is generated when tapping 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 the entry point.

Open the Start.smali file and again look for the line "Ad", find in lines 153 and 155 the mention of the FirstAd class. It is also in the source code and, judging by the name, is exactly 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 cond_10 label, 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 to show ads on the main screen, and, if not, jumps straight to cond_10. Ok, let's simplify her task and replace the conditional jump with an unconditional one:

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

There are no more references to FirstAd in the code, so close the file and reassemble our virtual torch using apktool. Copy to smartphone, install, launch. Voila, all ads have disappeared, and congratulations to all of us.

Outcome

This article is just a brief introduction to the techniques for cracking 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, it is only a matter of time to understand all this.

The ARC file with which we install the games is batch and, if necessary, extractable. This is very convenient, since already installed applications can be extracted into one file.

Often there are situations when, for example, you have completed a game and deleted it from your mobile device. But after a while we decided to play again. In order not to start the passage from scratch, it is enough to extract the ARC and use it when required. The entire completed process will be restored.

Extracting the APK comes in very handy when you need a friend over Bluetooth. In order not to install a special program, you can use the method that will be given below.

The ARC is extracted from installed applications using special software. A convenient file manager is perfect for this. Astro File Manager.

The file manager will help you manage the backup of the programs available in the device, watch videos and images, and the task manager. To extract the installation ARC without problems, you will need:

1. For Astro File Manager to function, you have to install it on your device, for which you need to look at Google Play. After completing the installation process, you can get to work.

2. Start Astro File Manager. A window will open on the screen indicating the available memory drives and a list of services in which you can register or log in.

3. Swipe to the left will open the main application menu. At the bottom left, click on the tools icon and go to the Application Manager.

4. You will see a list with all installed programs and games.

5. To extract the ARC, press the special button located in the upper right corner. Select BACKUP from the options provided. For clarity, I perform this operation with.

Now you just need to wait for the end of the process. All resulting files will be located in the Backups - Apps folder. They are installed as easily as regular APK files.

Many of you know that the process of installing an Android application is simple - you open the Google Play store, find the program or game you want, click on the big Install button and that's it. However, Android apps are packaged and manually installed. These packages have the extension ".apk" and their practical uses are numerous. For example, you can back up apps that are also stored as apk files without any problem. It will even help you in the event that an application or game suddenly disappeared from Google Play, as it did with Flappy Bird. If desired, anyone can download the application and install it on their smartphone. It is also convenient to install apk files on devices that are artificially limited by the manufacturer (Amazon Kindle Fire or Nokia X).

However, how can you extract the installed apk file? You can easily find the application on the Internet, download and install it on your Android device. This method works great with free apps. Paid ones are protected from downloading for obvious reasons. Additionally, applications that download additional files after they have been installed should work fine.

  • 1. On your Android google play device and download the app you want to extract.
  • 2. Download APK Extractor app. It is free and easy to use.
  • 3. Discover aPK application Extractor and specify any application you want to extract. Several applications can be marked at once. APK files will be saved in the ExtractedApks folder on the device memory.

Extracted APK files can now be copied to another Android smartphone or tablet and installed using any file managersuch as Astro or ES File Explorer.

One of the popular apps of this type... Lets you extract setup file directly from the official store and save it to your PC. In this case, the program does not even need to be installed on a PC - a portable version is available that fully works with external storage... When starting Raccoon for the first time, the user needs to enter credentials google account... The device ID is also requested, but this parameter can be ignored.

The application interface consists of two tabs: Download and Search. When searching, you can use the name, ID or link in the official directory. Having found the application, you can save it on your PC as a regular file, and then manually install it on another mobile device.


A popular alternative directory for Android featuring products from various developers. The directory client is small enough to be used on low-end devices. All programs are sorted into categories, there is a convenient search, and the applications themselves can be downloaded as files.

And then you can always use Clean master to quickly clean your phone from garbage. Do you know what it is? ...

APK Downloader

Extension for Chrome and Firefox browsers. Also allows you to quickly download the selected utility in the form a separate file... After activating the plugin, just go to the page desired program in Google Play and use the F5 key. The page is refreshed and the download button for the corresponding object is displayed.

other methods

There are also ways to download apk files without installing third-party software. For example, you can use the online service of the same name instead of the APK Downloader plugin. It is enough to open the resource, insert a link to the program into a special form and get a button, the activation of which initiates the download.

Another way: open desired page on Google Play and manually change to address bar browser play.google.com to apk-dl.com (the rest of the address must be left). After refreshing the page, the user is able to download the selected file.

Hello readers of our site. Once, one of the visitors asked for help, he needed to extract APK files from an Android smartphone. Thus, we decided to describe the answer to this question in this article. With this operation, you can make a backup of all installed applications on a smartphone, tablet or other gadgets that are running operating system Android.

When are installed applications backed up?

The first situation. You need to reset your phone to factory settings, but no internet access or only mobile. You don't want to download the apps from Google Play again later, as it will take a long time. It is for such cases that it is possible to extract APK files from an Android device or.

The second situation.You have installed an exciting game, the cache of which "weighs" a lot, and your friend liked it, and he wanted the same toy for himself, but, again, there is no Internet access. Here you will have to make a reservation installed game... You can find instructions on how to properly install games with a cache.

There are many such situations.

How to extract APK files from an Android device?

To accomplish this task, we need the free ES Explorer app, which can be found on Google Play. Why this particular conductor? It's simple, it's a great and easy-to-use file manager and it already has an integrated application backup feature. With this function, you can extract the desired APK files from Android devices.

Method 1.So, you have installed "ES Explorer", now let's launch it:

Picture 1

We go to the application menu for this, press the button we specified in the upper left corner of the device screen. Open the "Libraries" section and click APPs.

Figure 2

If you did everything correctly, a window with the installed custom applications... Next, select the application you want to extract and press the button Reserve at the bottom of the screen.


Picture 3 Picture 4

All extracted applications are in the folder « Phone memory /backups /apps ". You may have noticed that in Figures 3 and 4, some files are highlighted in red or green, and so: applications that were previously backed up and are in the folder are marked in green apps , and red - applications that were also extracted earlier but deleted from the folder apps (only the extracted files are removed, not the installed ones). That is, in principle, everything related to extraction by this method.

Figure 5

Now you can do whatever you want with these files: upload to a computer, send to a friend via Bluetooth or e-mail... Let us remind you once again - this method backs up only those applications that were installed by the user, but not the system ones. Use method 2 to back up system applications.

Method 2. We start the same "ES Explorer". At the top of the screen there is a choice of memory partitions (Figure 6) or go to the "Local storage" menu (Figure 7) and select the item /Device .


Picture 6 Picture 7

Next, you need to go to system / app ... All applications that are installed on the device are located here: both user and system applications. Then we look for the desired APK file and copy it to desired folder... Thus, you will receive a ready-made APK file for installation on other gadgets.

Warning! For both ways, you may have to. It is quite possible that some extracted system APK files may not be installed on other Android devices due to the fact that they are developed for a specific firmware.

That's all.

We hope that this post helped solve the problem and that you were able to extract APK files from an Android device. If you know of other ways of backing up programs or if you have similar questions - write to us.

Stay tuned, there is still a lot of interesting things ahead.