What is an APK file and how to install it on an Android device? how to open ark file on android

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, and get full version there is no possibility. How to change the situation?

Introduction

In this article, we will talk about how to disassemble an APK package with an application, consider it internal structure, disassemble and decompile the bytecode, and also try to make a few changes to applications that can bring us this or that benefit.

To do all this yourself, you will need at least basic knowledge 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

Package android apps, in fact, is a regular ZIP file, for viewing the contents and unpacking of which no special tools are required. 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, a list of required permissions, required android version and 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 to put their game engine written in C/C++ there, 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 unzip 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 the 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 full path before it in the app settings.

All information is provided for informational purposes only. Neither the editor 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 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. special attention the MainActivity.smali file deserves 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.

In order to expand the standard functionality of their smartphone, users prefer to download and install additional applications on it. And if iPhone owners need to use the iTunes Store for this, then Android users can perform the action with built-in tools.

First you need to set the settings so that you can install applications from unknown sources.

Now let's take a closer look, what is apk. All applications and files designed for Android have this extension. In fact, they are ordinary archived documents. They can be opened using special programs, archivers. Android devices recognize these files and by default know what to do with them.

Installing .apk files

There are several ways to install .apk applications. The easiest of them is to use the file manager. To do this, a document with the .apk extension must be saved to the memory card installed in the smartphone. Then you should open any file manager (for example) and find the desired file in it. After that, the installation will start using the standard system installer.

Another way to install the apk file is to use the Play Market. In order to complete the installation, you need to go to the application and find the desired program. After that, the button " Install”, and the process starts automatically. The only requirement to use this method is that you have a Google account to sign in to the app.

If a terminal is installed on the device, then the installation can be done using it. It needs to open a command prompt. The adb install command is written in it, then the file name and its extension (.apk).
In addition, application managers are used for installation. These programs are designed to simplify the installation of utilities through .apk. They will scan the SD card and find the files they need. After that, in order to install any application, you can press a couple of buttons.

From the foregoing, we can conclude that the topic of today's publication will sound like this: how install apk file on Android. Many people do not know how to do this, although in fact everything is very simple.

So, friends, let's start with a small introductory part. If you remember, then in, we installed the Navitel navigation system from the official application store, which is called the Play Market.

That is, we still don’t really know how what happened there: we just connected our mobile device to the Internet, went to the store, chose what we needed and clicked the “Install” button. This is all set.

But now we will do something completely different, because we already have a pre-downloaded installation file in the “apk” format and the Play Market itself in this case, we don’t need it at all:

So, for you to better understand, a file with such an extension is the program installer for the Android system. For example, if you installed programs on Windows yourself, you know that such files have the “exe” extension there.

From all of the above, the question follows: how to install the "apk" file, if not through the store? And here's how, read from now on very carefully. Further, we will consider everything using the example of the same Navitel Navigator.

Although there is no difference. For absolutely all applications, this procedure is exactly the same. All visibility in the article will be shown on the version of the Android 4.1.2 operating system.

And for starters, we definitely need to make one very tricky setting. Right now, select the "Settings" section:

And in the "Security" tab, check the box next to "Unknown sources". Screenshot below to help you:

Now we need to download the installation file itself with the "apk" extension. In our case, we find it on the official website of the program in the "Download" section:

Pay attention to the picture above. Quite often, when installing in this way, you will be prompted to select the screen resolution of your device. But if you don't know anything about it, choose the version that suits any display resolution.

After the apk file is downloaded to the computer, it will need to be copied to the memory card of your smartphone or tablet. To do this, connect to the PC using a cable:

As a result of this, on your mobile device A message will appear stating that the connection has been established. Now click on the "Enable USB storage" button at the bottom of the screen:

After that, the Android device will be detected on the computer as a regular flash drive, to which you need to copy the installation file:

Then again go to the settings menu by clicking on the icon in the upper right corner:

And in the "Applications" window that opens, select the "File Manager" item:

At this stage, you will see a list of folders, among which there is ours with the name "Download":

And finally, we see our apk file that needs to be installed on the Android system:

Click on it with your finger and the process has begun:

Now we are waiting for the end of copying files and you can run:

In principle, this is where all our science ends. We return to the "Applications" section and see the icon of the newly installed Navitel:

By the way, now in order to save space on the device's flash drive, you can delete the installation apk file of the application itself. To do this, return to the "Download" folder and do the simple combinations shown in the figure below:

That's all the wisdom, my dear friends, now we can say with confidence that you know exactly how to install . Agree that there is really nothing complicated here.

And now a few words about the program itself, on the example of which we considered the principle of installing applications in this way. If you are a motorist, you should appreciate the capabilities of Navitel Navigator.

Moreover, now you can easily install it on your mobile device and carry a full-fledged navigation system in your trouser pocket. You just have to download the necessary cards from the official website (link at the beginning of the article) and drop them into the appropriate folders:

By the way, it is worth saying that the folder structure of Navitel on Android is completely identical. So study and use it to your health so as not to get lost. 😉

And on this note, let me take my leave, if you have any questions, you are welcome in the comments to the article. And now it's time for complete relaxation and the author slowly but surely plunges into a trance.

Found among the files windows file with an unknown extension, we often get discouraged. The devil knows what this unrecognized "axis" is. Such thoughts come to the mind of many people when they first see the “apk” extension. Having an apk file, how to open this thing on Windows?

Before answering this question, it is necessary to understand what kind of beast this is in front of us. The .apk file format was developed by Google to store Android executable applications in this format. The very concept of storing programs and data in one archive is not new. Back in the early days of personal computers, packaging programs into an archive was very popular. To launch such applications, it was not even necessary to unpack this archive - the system tools did it on their own. This technology is also in circulation in the circles of developers and users. different kind emulators. Therefore, the idea of ​​Google is not something unusual or unexpected.

"Apk" stands for simply - "Android Package". This is an ordinary archive, which can be opened by almost any archiver available for Windows.

Inside the archive are the following application components:

  • Program source code.
  • Application resources like pictures, sounds, etc.
  • A special file called manifest.

Those wishing to open such a file with an archiver will need to follow our further instructions.

We perform an autopsy

Since apk is an archive, we will try to open it with an archiver program. Many multifunctional archiving programs have been developed for Windows that can create and open archives of almost any format. APK files are no exception. Let's point out two such archivers for Windows that successfully cope with this task: WinRar and 7-zip. If the first of these programs is commercial, then the second is completely free, and you can download it directly from the website of its developer, Igor Pavlov, at: http://www.7-zip.org/ or http://7-zip .org.ua/ru/.

Install the 7-zip archiver in Windows (unless, of course, this famous program has already found a home on your computer).

Right click on the required apk file. The context menu should appear as usual.

Select the menu item "7-zip" - a submenu will appear with a choice of options.

We ask the archiver to open the archive or extract data from the archive. It can be done different ways, by selecting one or another submenu item, for example, the “Open archive” item (only to view the contents) or the “Unpack” item. The user will be prompted to specify the unpacking folder and other optional parameters.

That's all you need to know to open a file with the "apk" extension.

In this article, we will tell you how to open an APK file. Follow the instructions exactly and you'll be fine.

What is APK? This is a regular installer or archive of source files for any application created for the Android platform. It stands for Android PacKage. Some users of android devices complain about problems installing such files. Let's take a closer look.

Initially, you need to give your phone access to third party applications(applications downloaded from the Internet, not from Play market) and allow them to be installed on the phone. To do this, you need to carry out several manipulations with the settings: go to "Settings", then to the section "Personal data" / "Personalization" / "System" (on all phones in different ways).

Now the phone will install any downloaded applications. Please note that by downloading such "left" programs, you risk losing valuable information, such as passwords, numbers bank cards and just personal information. Nobody canceled hacking and viruses. Be careful and vigilant with downloaded files.

Tip: Be sure to download antivirus program to protect your device.

So, there is access. Now you need to get to the file itself, as on a regular computer. Almost any file manager will help you with this. It is he who will allow you to use and open downloaded APK programs.

Download absolutely any. We prefer X-Plore File Manager (Download). In our opinion, it provides the most detailed and conveniently structured information about smartphone files and, in addition, has excellent functionality.

In most cases, just click on the icon of the downloaded application and it will start.

But if it doesn’t work out, then use the “Open in the system” function, which allows you to use absolutely all possible programs to open.

Before installing, be sure to read the app's permissions. Some of them request access to personal information. In that case, think 20 times before using such applications.

And in general, it is better to purchase licensed software and other software.

Dear readers! If you have any questions or comments on the topic of the article, please leave them below.

Have questions?

Report a typo

Text to be sent to our editors: