Internet Windows Android

Deodexing and deodexing Android firmware. What is odex and deodex in Android What is deodexed firmware

Sooner or later you will come across such concepts as Odex and Deodex. It is especially important to know about them at the moment when the user decides to change the firmware. Not everyone can correctly explain Odex and Deodex - what is it? Sometimes this makes it difficult to select and install the right software on your mobile device. As a result, the operation of a smartphone or tablet does not meet the user’s expectations. The fact is that all users can be divided into two categories. The first values ​​stable, fast and reliable operation. Such users rarely use custom firmware on their devices. The second category, on the contrary, prefers to completely customize the gadget based on individual needs. Such users often use custom firmware, gain root rights and are not afraid to change important parameters at their own risk that affect the operation of the operating system of the tablet or smartphone. In any case, information about what the difference between Deodex and Odex is will be useful for all categories of users, regardless of their needs for using mobile gadgets and their attitude towards changing important settings.

The difference between Odex and Deodex firmware, as well as their advantages and disadvantages

What are Odex and Deodex?

Odex is a general concept that implies the factory firmware of a mobile gadget operating on the Android operating system. Sometimes they are called dexed. Deodex is a custom version of the firmware or, as some say, deodexed.

Each program has an executive section. In a custom operating system, Android is located in the classes.DEX file, while the original version contains an executive section in the Dalvik Virtual Machine virtual machine of the operating system. Odex stands for "Optimized Dalvik Executable File". The principle of operation of the Odex file is that it allows the operating system to receive data directly, without searching and unzipping information from files with the apk extension.

What is Deodex firmware? This is a software variant in which the executable section of the application is repackaged into a classes.dex file, and then moved back to the apk file. This allows you to store all program elements in one section, while reducing the risk of causing the application to malfunction while changing user settings.

Finding out whether Odex or Deodex firmware is installed on your mobile device is very simple. To do this, the user needs to use a file manager. The user needs to go to the /system/app folder. Depending on the extension of the files contained in the folder, you can determine the type of system. The odex extension refers to the odexed version. If you do not find the file in the system folder, this means that deodexed firmware is installed on the mobile device.

Advantages and disadvantages

It is impossible to say clearly which is better - Odex or Deodex? Both options have their advantages and disadvantages. The advantages of the coded version are that applications launch much faster. This becomes possible thanks to the pre-loading of information by the system. At the same time, files with the apk extension require less device memory.

The advantages of deodexed systems are that it is much easier to uninstall an unnecessary application. To do this, you simply need to delete the apk file, which is responsible for the operation of the program. It is also important to note that modifying the operating system is much easier, since the data is placed in one .

A dexed shell is much more difficult to hack because it takes data from two different partitions. There are specifics to uninstalling programs, so we recommend that you follow this process carefully. Files with the odex extension should also be deleted. The disadvantages of deodexed shells include slower operation, which occurs due to automatic clearing of the cache, which stores data from the most popular programs.

How to make a Deodex version?

There is a simple way by which you can make Deodex firmware from deodexed one. To do this, you need to download and install the xUltimate utility. Then you need to follow a few simple steps.

What are Odex and Deodex?

The system/app folder contains APK and Odex files. Deodex - means that all odex files are included in the APK and are not in the system/app folder. The Deodex system is convenient for editing, but it is considered to be more unstable and slower, but in practice, I personally am fine with it. Odex files are packaged dex code modules that are usually found inside an apk. Used Dalvic VM to speed up application launch.

To speed up the loading of Dalvik VM, the executable code (classes.dex) can be moved from programs (.apk files) to separate files with the .odex extension. As a rule, factory (official) firmware is installed in this form. The disadvantage of this solution is the impossibility of customizing the interface.

converting executable code from .odex files back into program files (.apk).
To install Deodex"ed firmware, you usually need Root and CWM Recovery or another modified recovery (TWPR, Philz Touch, etc.).

You can find out the Odex or Deodex firmware as follows.
If the system/app folder contains only files with the APK extension, it means deodex firmware, if there are files with the odex extension, then it means odex firmware. All official odex firmware. Almost all modified firmware are deodex, but among the modified ones there are also odex firmware.

What does it mean to install Deodex?
Let's say you've already made or found the same deodex files for your firmware. Now you need to upload them to the system/app folder, but you cannot simply replace them through Explorer, since the system can currently use them. There are ready-made files for this. They (the files) are placed in a special ZIP archive with a script for mod recovery (you can write this script yourself), and all you have to do is install this archive using any modified recoveryinstructions for installing zip files

This ZIP archive is an archive with deodexed files, and with installation instructions via mod. recovery. If you have a Russifier installed, then after installing deodexed the Russian one will disappear, no big deal, the Russian one will just need to be installed again. This happens because in Android the interface language is described by an XML file contained in the apk. Russification occurs by adding Russian xml to the apk, and when you install the Russifier on your system, the old apk is simply replaced with new Russified ones. Installation of the crack is carried out using the same ZIP for the mod. recovery like deodexed. Russified files have already been deodexed, because we cannot edit odex files. The deodexed archives that we have are taken from foreign sites, so there is no Russian in them, so after installing them you have to re-install the localizer.

After installing deodexed, all system applications are restored and replaced, all for the same reason described above. Therefore, deleting system files must be done after installing deodexed.

Each of you has heard the words “deodex” or “odex” more than once. Usually, they are found where various firmware for your device are posted, for example, on XDA-Developers or 4pda. So what does it mean, DEODEX or ODEX? What are their differences? How to make DEODEX? You will find answers to these and other questions in the next issue of the digest “What is...”.
Odex (Optimized Dalvik Executable File) is a file located in the same folder with system applications, which stores the code of the program itself. As you know, every program needs instructions, thanks to which it (the program) will perform one or another function or work. This is exactly the program code that I described earlier. If you want to modify any system file, you will need to dig into both the odex file itself and the .apk when installing the odex firmware. From this it becomes clear that this process will not be very easy. It is for this reason that the possibility of deodex firmware was implemented.

As you already know, in odex firmware the files are stored “randomly”. However, with deodex there is no such disorder, so to speak. All files in deodex are stored like a .zip archive, but in our case they are “packed” into .apk. For this reason, disassembling the application for further modifications becomes easier, and due to the fact that everything is packed in one place, the deodex firmware will perhaps take up less space.

However, deodex cannot be praised endlessly. The main disadvantage of deodex is that applications take a little longer to load than on odex. Most likely, the user will not notice this. But I can’t help but note that both the advantage of odex and the disadvantage of deodex is that all system applications in odex are optimized for a specific device by the manufacturer itself. And this is undoubtedly a plus of odex firmware.

I almost forgot to mention that when installing various ready-made modifications to the system for your device, you need to have deodex firmware.

Probably, in this situation, the meaning of the terms is clear. And I'm willing to bet that some people already want to try deodex. There are a huge number of instructions for deodex firmware on the World Wide Web. However, I won’t dare send you to search for them on Google, but I will simply silently write down this whole process, trying to highlight all the little things.

The instructions for different versions of Android are not the same. Due to the fact that Android 5.0 Lollipop is installed on my device, I will write instructions for deodex specifically for this version.

  1. First, we need to download a special utility, JoelDroid Lollipop Batch Deodexer, to our PC. This utility requires a Java program to operate. I note that in frequent cases, a Java application writes its path incorrectly and incorrectly. For this reason, you need to manually register this path according to these instructions.
  • After this, we need to install on our device running on Android 5.0 Lollipop any file manager through which we need to copy the three main system folders - APP, PRIV-APP, FRAEMWORK - to a separate folder on the SD card. They are located in the root folder System.


  • Next, we need to create the MyROM folder in the root of any internal drive on your PC. Then we create another folder in this folder, but with the name System. In theory, you should get the following path - E:\MyROM\system. Where "E" is your internal storage (hard drive)
  • Those system folders that we copied in the second step need to be moved to the E:\MyROM\system folder.
  • Now, in theory, we have prepared everything, and we can already proceed to the DEODEXATION point.
  • Launch the previously installed JoelDroid Lollipop Batch Deodexer utility.
  • By clicking the “Browse” button in the utility, we need to show the path to E:\MyROM\system
  • The path is indicated, everything is ready. All we have to do is press the “Start Prosecc” key, after which deodexation will begin. This procedure takes about 10-15 minutes.
  • After deodexation is complete, we need to copy the resulting files, which are located along the path E:\MyROM\system, to a MicroSD flash drive on your device.
  • Next, we need to download AROMA FileManager and install it via custom recovery on your device. But before installing, we need to select System in the Mount section if it is not selected.
  • After all this, we must go to the root of the file system and delete the APP, PRIV-APP and FRAEMWORK folders from the System folder, just delete them, since when copying the ARM folders will remain, and the whole process, consider it, has gone down the drain.
  • Next, copy the deodex folders previously transferred in step 9 to the System folder in the root of the entire file system.
  • After this, we need to flash a script that sets permissions for folders (RWXRX-RX), .apk files and .xml files (RW-R-R)
  • Next we need to make wipe cache and wipe dalvik/art. Reboot the device and enjoy the deodex firmware you received.

  • Make sure that you have DEODEX installed - you can update the firmware using the following short instructions: D


    I fully believe that I have talked about the most basic things about the terms ODEX and DEODEX, and this article can be completed. Thank you all for your attention, please rate the article, have a good day and a successful SUMMER!

    Hello Habr!

    Several years ago, when I was first introduced to Android, I heard from a work colleague that Android provides the ability to install modified or homemade firmware. Frankly, I was far from it then. And even half a year ago I was barely interested in such things. Deep in my heart, I was sure that what the manufacturer was doing was already intended for normal use.

    Imagine my disappointment when I purchased a phone from China, where the factory settings prohibited the use of Google, Skype, Facebook and other applications. In principle, it was possible to turn a blind eye to some things, but when my phone did not require the use of a Google account, I made promises to definitely figure it out no matter what happened to me.

    Half a year has passed and my custom firmware is being successfully used all over the world.

    This series of articles will discuss how to do reverse programming for Android, implement patches, tweaks and mods.

    Preamble

    So! Let's first define the concepts that will be used in given article. Your usual understanding, however, may be very different.

    Patch- changing or replacing existing program code in order to modify the program algorithm.
    Maud- as a rule, adding additional functionality to existing program code without changing the algorithm.
    Tweak- improvement of the program functionality in order to facilitate access to system parameters.

    I also want to note that all examples will be taken for an HTC phone, but this does not mean that this information cannot be used on other phones.

    Preparing the environment

    I can do without detailed instructions on how to use this or that software. If you are interested in this article and have read this far, then I hope that you are already an experienced user and have experience using, or at least experimenting in, this area. There are plenty of instructions, articles and test results in the public domain, just like on Habré. I will also do without describing some terms, otherwise the article will turn out to be very long and tedious. We will write only to the point. I'm sure you've been on Wednesday for a long time. If not, then I suggest downloading and installing it.

    1 . Android SDK. This is an application development environment for Android. In order to make modifications, we will definitely have to check our program code. The development environment is the best we can use.
    2 . Android Kitchen. This utility will allow you to work with images of system partitions of official or unofficial firmware.
    3 . JD-GUI. Java code decompiler. I would like to note right away that this is the best decompiler in terms of ease of use.
    4 . DJ Java Decompiler. Another decompiler, or disassembler, as some like to call it, of Java language program code. It is not convenient to use, but it parses code that JD-GUI sometimes does not understand.
    5 . smali. Another disassembler, but this time dalvik code. smali is needed for disassembling, and backsmali is needed for assembling code.
    6 . dex2jar. A utility for converting Dalvik code executable files.

    Firmware conversion

    Of course, the firmware that you have on your phone from the manufacturer is optimized to reduce power consumption. In order for the firmware to be modified, it must be converted into a format that allows the code to be modified. Android Kitchen is used for this. Of course, you can do it with your hands, as I did before until I found this very “kitchen”. You can read on the Internet how to remove the system area from the phone, install the environment, and make DEODEX firmware. If you don't understand anything already, I think it's worth holding off on reading this article until you gain enough experience.

    After the firmware has changed from an optimized version (ODEX - optimized dalvik executable code, if my memory serves me correctly) to DEODEX (that is, NOT optimized), all executable files are ready for modification.

    Direct modifications

    Creating patches
    As I already said, my phone was initially banned from using Google. Well, no matter what, you can’t go to the Playstore, you can’t set up an account, the phone book doesn’t really sync. Why do you need such an Android? After digging for a long time into the logcat of the device itself, I found entries that said that the use of Google is prohibited. The most inconvenient thing about Android is that you see the log, but you don’t know which system application is producing it. To find where my legs were coming from, I had to gut all system applications to disassembled Java code. It took a lot of time, but I still use the work I did when analyzing and finding the right code. The steps to obtain such tools are as follows:
    1 . Make DEODEX of all firmware
    2 . Your new DEODEX firmware will need to be assembled and flashed onto your phone. How this is done is the topic of another article.
    3 . From each file located in /system/framework, extract the classes.dex file and convert it to JAR using dex2jar.
    4 . Open each resulting JAR in JD-GUI and re-save it into source code
    5 . Unpack the source code from the archive.

    In the end, I ended up with as many folders as there were JAR files in /system/framework, and each folder had a Java source code structure.
    Through simple manipulations, I quickly found the place that generated entries in logcat.

    We will not consider the entire logic of the ban, since each case is a separate story. I had to spend a couple of hours before I found where the checks were made, built a block diagram of the algorithm in my head and understood where to go in order to “spoil” the algorithm a little.

    It turned out to be simple. There is a subroutine that, based on pre-established constants, when contacted, answered whether the phone belongs to China or not.

    The code was in the file HTCExtension.jar, and the class that contained this subroutine was in

    Unpacking and analysis of the original file
    1 . First, we need to take the original DEODEX JAR file, which is responsible for the part of the code we need. In our case HTCExtension.jar.
    2 . Open with any archiver and pull out classes.dex from there
    3 . Use the dex2jar converter to convert it to a JAR file. Command: dex2jar.bat classes.dex
    4 . Open the resulting classes_dex2jar.jar file in JD-GUI.
    5 . Yes, most often JD-GUI decompiles the code not as it looks in the original, it is understandable, but it is quite readable. In the source code we see that the subroutine checks the project parameters and the firmware language flag. In our unfortunate case, TRUE is returned.
    public static boolean isChina() ( if ((HtcBuildFlag.Htc_PROJECT_flag == 216) || (HtcBuildFlag.Htc_PROJECT_flag == 218) || (HtcBuildFlag.Htc_PROJECT_flag == 23)); while (((HtcBuildFlag.Htc_PROJECT_flag == 1) && (2 == HtcBuildFlag.Htc_LANGUAGE_flag)) || (HtcBuildFlag.Htc_PROJECT_flag == 27)) return true; return false; )
    6 . To make a patch, we need to disassemble the Dalvik code itself. For this we use baksmali. The most convenient way is to create a separate folder and put three files there together: HTCExtension.jar, smali.jar And baksmali.jar. Give the command java -Xmx512m -jar baksmali.jar -a -d -o HTCExtension -x HTCExtension.jar

    This is the API for your version of Android. For JB it's 16
    - the folder where all the firmware frameworks are located.

    In my case it was the command
    java -Xmx512m -jar baksmali.jar -a 16 -d S:\dev\Android\Android-Kitchen\WORKING_JB_15\system\framework -o HTCExtension -x HTCExtension.jar
    7 . In our newly created folder, the HTCExtension folder appeared, and in it our files with Dalvik code.
    8 . Finding the file along the path \com\htc\util\contacts\BuildUtils$Customization.java and look at the code:
    .method public static isChina()Z .registers 3 .prologue const/4 v0, 0x1 .line 276 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, 0xd8 if-eq v1 , v2, :cond_13 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, 0xda if-eq v1, v2, :cond_13 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag ;->Htc_PROJECT_flag:S const/16 v2, 0x17 if-ne v1, v2, :cond_14 .line 297:cond_13:goto_13 return v0 .line 283:cond_14 sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;-> Htc_PROJECT_flag:S if-ne v1, v0, :cond_1d .line 285 const/4 v1, 0x2 sget-short v2, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_LANGUAGE_flag:S if-eq v1, v2, :cond_13 .line 291:cond_1d sget-short v1, Lcom/htc/htcjavaflag/HtcBuildFlag;->Htc_PROJECT_flag:S const/16 v2, 0x1b if-eq v1, v2, :cond_13 .line 297 const/4 v0, 0x0 goto:goto_13 .end method
    9 . Scary, isn't it? Nothing is clear. But this is a fixable issue. Having created several of your own patches and thus gained experience, you can easily modify the code without third-party tools. In our case, in this code
    .prologue const/4 v0, 0x1 assigns the variable v0 the value 1, that is, TRUE. Then there are all sorts of checks, and if the phone is not Chinese, then the value of the variable changes:
    .line 297 const/4 v0, 0x0 goto:goto_13
    10 . The easiest way to save the father of Russian democracy is to change the code to the following:
    .prologue const/4 v0, 0x0 , that is, change the value of the variable from 1 to 0. That is, no matter what, the value FALSE would always be returned and in the JD-GUI the code would look like public static boolean isChina() ( if (( HtcBuildFlag.Htc_PROJECT_flag == 216) || (HtcBuildFlag.Htc_PROJECT_flag == 218) || (HtcBuildFlag.Htc_PROJECT_flag == 23)); while (((HtcBuildFlag.Htc_PROJECT_flag == 1) && (2 == HtcBuildFlag.Htc _LANGUAGE_flag)) || (HtcBuildFlag.Htc_PROJECT_flag == 27)) return false; return false; )
    11 . Yes, the method will work. But we are not looking for easy ways - this time. Secondly, it’s not exactly beautiful. I would like code something like
    public static boolean isChina() ( return false; )
    12 . How can we get the Dalvik code for this source code? For beginners we will do a little trick.

    Creating Dalvik code
    1 . Open Android SDK.
    2 . We create a new project, and write the following code in our only test class
    package ru.habrahabr.test; public class test ( public static boolean isChina() ( return false; ) )
    3 . We compile our project and then take the assembled application from the workspace.
    4 . We put the assembled application in the folder where we gutted the JAR file.
    5 . Give the command java -Xmx512m -jar baksmali.jar -a -d -o test -x test .apk
    6 . We disassembled the newly built application into Dalvik code.
    7 . Open our test.smali file and see the code there
    .method public static isChina()Z .registers 1 .prologue .line 7 const/4 v0, 0x0 return v0 .end method
    8 . That's it, the patching code is ready.
    Rolling a patch
    1 . Dalvik code is littered with markers indicating a line of code in the original source file. This is necessary when displaying errors, if any, in your program. The code also works fine without specifying lines.
    2 . We delete the lines with line numbering, copy and replace the method (subroutine) in our \com\htc\util\contacts\BuildUtils$Customization.java file.
    .method public static isChina()Z .registers 1 .prologue const/4 v0, 0x0 return v0 .end method
    3 . Save the file. Yes, I forgot to say, you need a normal editor, for example Notepad++ or EditPlus. Who likes which one?
    Compiling and building a patched JAR file
    1 . Using backsmali, we gutted our JAR file, and now we need to put it back together.
    2 . Give the command java -Xmx512m -jar smali.jar -a 16 HTCExtension -o classes.dex
    3 . The classes.dex file appears in our folder
    4 . Opening again HTCExtension.jar file with an archiver and replace the existing one in it classes.dex to our just created one.
    5 . That's it, ours HTCExtension.jar contains modified program code.
    Replacing the original file with a patched one
    Usually, special scripts are created for ordinary users, which are replaced via recovery. But we are not interested in this. Firstly, it’s long and tedious, and secondly, we are experienced users and can afford some subtleties.

    1 . You can replace the current working file with the following commands if you already have DEODEX firmware and have root access:

    Adb push HTCExtension.jar /sdcard/HTCExtension.jar adb shell su mount -o remount -rw /system dd if=/system/framework/HTCExtension.jar of=/system/framework/HTCExtension.jar.back dd if=/sdcard /HTCExtension.jar of=/system/framework/HTCExtension.jar chmod 644 /system/framework/HTCExtension.jar rm /data/dalvik-cache/system@ [email protected]@classes.dex reboot

    The first command uploads the patched file to the flash drive
    2nd command opens shell
    3rd command gives root access
    The 4th command mounts the system in read/write mode
    5th command makes a backup copy of the file
    The 6th command overwrites the existing file with the new patched one.
    7th command configures permissions
    8th command deletes cache
    The 9th command reboots the device.

    2 . Thank you for reading to this point, there is little left.
    3 . After a reboot, your new patched code will take effect.
    4 . If the code does not work or an error occurs, then using simple combinations you can return the backup copy.
    adb shell su mount -o remount -rw /system dd if=/system/framework/HTCExtension.jar.back of=/system/framework/HTCExtension.jar rm /data/dalvik-cache/system@ [email protected]@classes.dex reboot

    Epilogue

    Yes, some thought this article was too specific, some found it difficult to understand, and some found it useless. I deliberately avoided in-depth detail and illustrations of how it all looks live and in practice. Firstly, this work will be thankless and will only give rise to even more questions. Secondly, I don’t want to see an army of users on forums complaining that they killed their phone.

    For the next article I will tell you how to make Tweeks. There will be an example of using automatic recording of phone calls using native phone tools. Thank you for your attention.

    P.S. If something is not clear or confusing, ask questions - I will always be happy to answer and explain.

    In this short note, we will tell our readers about deodexing firmware for Android using jBart, as well as the difference between ODEX and DEODEX firmware. First, let's figure out what is meant by the terms odex / deodex by using the following links:

    At the time of writing this note, the current version was jBart v1.8.9 -"The program is designed to automate the process of translating firmware based on the Android OS. Android versions are supported from 2.x.x to 4.x.x (including Android 4.4 KitKat). The core of the program is a modified apktool. In addition to translating firmware, there is the possibility of deodexing firmware, and also work with single apk and jar files from firmware."

    Without dragging out the story for too long, let's move on to a practical example. We will “train” on the firmware from MTS, which we wrote about not so long ago. The first step is to download the /system/app and /system/framework folders, as well as the build.prop file, from the tablet in one way or another. which can be found in the system folder. To copy some parts of the firmware you may need root rights (on the Oysters T7V 3G you can easily get them using the application motochopper, which you can easily find in search engines). After we have downloaded the necessary files and folders, we place them in the system directory and pack them into an archive - system.zip, so that the root of the archive contains the system folder, and inside it there are subfolders app, framework and the bulid.prop folder:

    We select the correct version of the ROM API (i.e. the Android version), in our case it is 4.2.x, press the Deodex button and wait. Upon completion of the operation, the archive with the deodexed firmware will be located in jBART-master\output\deodexed_system.zip. As you can see, the firmware files no longer contain .odex files, but only .apk. Now you can proceed to their modification, translation, editing, etc. changes. But this is a topic for a completely different note. To summarize, we note that with the help of jBart and several simple operations, we learned how to get deodexed firmware from deodexed firmware, i.e. "custom". Files in which everyone can modify according to their desires and needs.