Ways to merge apk and Odex

Source: Internet
Author: User
Tags zip

This method is very early people said, the following is my own operation and then re-organized, I hope that everyone can help.

There are many Odex files in the Android ROM, what does this Odex do with the Dex file in the APK? If you look closely you will find that the file name corresponds to one by one and that there is no Dex file in the corresponding apk file. This will enable their manufacturers to guarantee a certain anti-piracy, because there is no Dex file apk is not installed properly, and manufacturers directly put Odex and incomplete apk files to the phone ROM cured to/system/bin can be used by ordinary users to export.

It may be thought that merging Odex and apk into the APK contains Dex files, so the combined final APK file is installed in the/data/, and ROM is stored in the/system/app, so that the user can be installed on the Android phone software will become less, occupy the system space.

Here's how to repackage and sign the method:

First, the APK generation Odex file Method:
Compile the source code on a Linux or virtual machine, and in the/root/working_directory/out/target/product/generic/system/app directory, you will see the corresponding APK package and the Odex file.


Second, merge Odex and less Dex apk for the full apk file

1. Download the latest Smali and Baksmali at the following URL:

Http://code.google.com/p/smali/downloads/list

Attention must be updated, if not the latest, will be an error:

Unexpected top-level EXCEPTION:
Java.lang.RuntimeException:bad Magic value:64 0a 30 33 36 00
At Org.jf.dexlib.dexfile.<init> (dexfile.java:382)
At Org.jf.baksmali.main.main (main.java:249)

When merging Odex, copy all the files in the framework in the phone ROM, that is, in the/root/working_directory/out/target/product/generic/system/framework directory, The files to be decomposed are placed in the same directory, and in order to reduce errors, it is best to pull them all out, which avoids the following errors:

Error occured while loading boot class path files. Aborting.
Org.jf.dexlib.Util.ExceptionWithContext:Cannot Locate boot class path file Core.odex
At Org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath (classpath.java:237)
At Org.jf.dexlib.Code.Analysis.ClassPath.initClassPath (classpath.java:145)
At Org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex (classpath.java:110)
At Org.jf.baksmali.baksmali.disassembleDexFile (baksmali.java:96)
At Org.jf.baksmali.main.main (main.java:278)



2. Generating a class file from Odex

Through the cmd command, go to the directory of the tool you just downloaded, and then execute the following command:

Java-jar Baksmali-1.4.1.jar-x Package.odex

After executing this line of command, an out folder is generated with the Package.odex class file. (In the event of a problem, the prompts can be generated from the **.jar in the/system/framework of the ROM to the Java environment variable on the PC.) )

3. Generate the Classes.dex file through class.

Use the following command to generate the Classes.dex file.

Java-xmx512m-jar Smali-1.4.1.jar Out-o Classes.dex

4. Place the Classes.dex in the APK file

Because the APK is a zip MIME encoding type, use WinZip or winrar to drag it directly into the archive that the APK is renamed to zip.

5. Don't forget your signature, use the Arsigner and Keytool in the JDK to pack and re-sign.

Sometimes found that others have a cell phone apk is very good, want to get out to install their own mobile phone, but found that the APK is incomplete, there is no Classes.dex file, but there is an apk with the same name of the Odex file. The missing apk is not able to fit, only the APK and Odex can be combined into a full apk to install. The tools you need:

1. Smali-1.4.1.jar and Baksmali-1.4.1.jar

2. There are also some jar files in the ROM where the APK resides, all inside the/system/framework: Core.jar, ext. jar, framework. Jar, Android.policy. jar, services. Jar.

Of course, these five are the most basic, probably not enough, this situation will be discussed below.

A total of four steps:

1. The downloaded Smali-1.4.1.jar and Baksmali-1.4.1.jar, as well as the 5 jars that were keyed out in the ROM, are put into the working directory, and the APK and Odex are also put together.

2. Explode the Odex file as a class file. Command: Java-jar Baksmali-1.4.1.jar-x is the name of the Odex file you want to break up, and after the command is completed, an out folder is generated, which is all the class files. If there is a problem, such as what is abnormal, the lack of a package or something, it is more into the ROM inside the error message inside the required package out, put into the current directory.

3. The class is born as a Classes.dex file. Command: Java-xmx512m-jar smali-1.4.1.jar out-o Classes.dex This step should not have any problem, then the Classes.dex file will be generated.

4. Put the classes.dex into the APK and cover the lid. The final step is the simplest, using the decompression software to open the APK, and then the painstakingly generated Classes.dex plug in, OK. This apk will work. If you want to re-sign his name, go and find an Auto sign signing tool to sign the line.

Attach apk merge Odex file and apk signature download address: http://download.csdn.net/detail/xiaoyaovsxin/4980234

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.