We can think of merging odex and apk to make apk contain dex files, so that the merged apk files will be installed in /data/ and the rom will be stored in /system/app, which will eventually lead to less software that users can install in Android phones and occupy system space.
1.APK method for generating odex file;
Compile build/tools/dexepropt/dex opt-wrapper on open source GIT, just use dexopt-wrapper and follow the steps.
Put dexopt-wrapper into the /data/local directory, execute linux command line with adb shell, and enter the /data/local directory with cd command.
CD/ data/local
. /dex opt-wrapper Android 123 . apk Android 123 . odex
Second, merge the apk of odex and less dex into a complete apk file.
1. Download 1.2.2.jar and baksmali-1.2.2.jar. Since they want to be pirated, they need some reference classes in the rom where odex is located, generally in the /system/framework directory.
2. Generate class files through odex.
Java-jar baks Mali- 1 . 2 . 2 . jar-x Android 123 . odex
After executing the above command line, a class file with android 123.odex in the out folder will be generated. If there is a problem, it can be generated from * *. Jar in /system/framework of rom is converted into java environment variable on pc.
3. Generate the classes.dex file through class.
Java-xmx 5 12M-jar smali- 1 . 2 . 2 . jar out-o classes . dex
4. put classes.dex in the apk file.
Because apk is a mime encoding type of zip, it can be directly dragged into the compressed package with winzip or winrar, and the apk is renamed zip in the compressed package.
5. Don't forget to sign, just use arsigner and keytool in jdk to package and re-sign.
Sometimes I find that the apk of someone else's mobile phone is very good, and I want to take it out and install it on my mobile phone, but I find that the apk is not complete. There is no classes.dex file, but there is an odex file with the same name as apk. Incomplete apk can't be installed, only this apk and odex can be combined into a complete apk for installation. Tools required:
1.smali-1.2.2.jar and baksmali-1.2.2.jar.
2. There are still some jar files in the rom where 2.apk is located, all of which are in /system/framework: core.jar, ext.jar, framework.jar, Android.policy.jar, services.jar ..
Of course, these five items are the most basic and may not be enough. This situation will be discussed below.
Total * * * is divided into four steps:
1. Put the downloaded smali- 1.2.2.jar and baksmali- 1.2.2.jar, as well as the five jars dug out from rom into the working directory, and then put apk and odex together.
2. Decompose the odex file into a class file. Command: Java-jar baksmali-1.2.2.jar-x is the name of the odex file to be decomposed. After the command is completed, an out folder will be generated, which contains all the class files. If there is any problem, such as any abnormality or missing package, go to rom to take out the package needed in the error message and put it in the current directory.
3. Generate this class as a classes.dex file. Command: Java-xmx512m-jarsmali-1.2.2.jarout-o classes. dex There should be no problem in this step, and then the classes.dex file will be generated.
4. put classes.dex in apk and cover it. The last step is the simplest. Open apk with decompression software, and then insert the painstakingly generated classes.dex, and it will be ok. This apk will work. If you want to re-sign his name, just find an automatic signature tool to sign it.