I am looking for a proper and simple method to odex an apk file. I have an upgraded apk file from a ROM with which I want to replace the older one and it is located in the /system-priv directory. The older apk has the .odex file, but I figured out I can't directly overwrite the it, since I can't use the old .odex (hence I need to odex first), lest I'ill be stuck with app crashes or bootloops.

I have tried searching for methods online but are not satisfactory in one of the ways:

  1. This one which involves the use of a dexopt-wrapper.bin seems to be way outdated as binary is not supported, I have this error poping up:

     error: dexopt-wrapper error: only position independent executables (PIE) are supported.
  2. The second one which is lengthy and links to other required resources are no longer there, and is somewhat not compatible with my system.

  3. The only promising one which uses Auto Odexer Script, but currently I'm running issues adb and also seems it uses the same dexopt-wrapper binary which was giving me errors in terminal.

There are tools/methods for doing the entire system at once, but I do not need the entire system re-odexed. I want to personally create an odexed "upgraded" .apk from the extracted ROM.


I upgraded the wrapper binary (now PIE) and should be compatible however still encountering this error:

--- BEGIN '/sdcard/app/A.apk' (bootstrap=0) ---
--- waiting for verify+opt, pid=17200
--- would reduce privs here
execl(/bin/dexopt) failed: No such file or directory
--- END '/sdcard/app/A.apk' --- status=0x4300, process failed
1|mido:/ #

and the result is an empty .odex file in the dir. Someone to point out where I am going wrong here?


credits to com.modaco.odexme xda link

Theoretically you should only need your Android device to manually odex, I ended up using both smartphone (running KitKat 4.4) and PC as explained later.

I successfully odexed apks using the following steps:

1.Create a /dir/odex on your Android device

2.Save next script as odex.sh in /dir/odex, give it execute permission 777


cd /dir/odex

for filename in `find . -name '*.apk'`

# step 1 - odex the apk
./dexopt-wrapper $filename `echo $filename | sed 's/\(.*\.\)apk/\1odex/'`

# step 2 - did we succesfully odex?
if [ -f `echo $filename | sed 's/\(.*\.\)apk/\1odex/'` ]
    # step 3 - remove the classes.dex from the apk
    ./zip -d $filename classes.dex

    # step 4 - zipalign, just in case
    ./zipalign -f -v 4 $filename $filename.new
    mv $filename.new $filename


3.Obtain following binaries from com.modaco.odexme.apk\assets

dexopt-wrapper zip zipalign

put those in /dir/odex and give execute permission 777

4.Copy .apk(s) you want to odex from /system/app or /system/priv-app to /dir/odex

5.Open Terminal, cd to /dir/odex and execute ./odex.sh

At this point I had a problem with zipalign which could not LINK EXECUTABLE - cannot locate symbol... but nonetheless script partially executed and obtained odex(es) sitting next to apk(s) in our dir.

6.So I had to resort to the PC, copy original apk to PC, open it with WinRar or 7zip, manually remove classes.dex and zipalign, than put "deodexed" apk back to Android device.

7.Now with a file explorer put newly created .odex and .apk in /system/app or /system/priv-app (have a backup of original apk first). If it fails to write mount system as rw. Give both permission 644 as all the other apks and odex in dir.

8.You can now delete corresponding dex in /data/dalvik-cache

9.Reboot (or soft-reboot)

10.Enjoy your newly odexed app

I successfully odexed LGEIME.apk, a modified keyboard for my G2, and GoogleDrive.apk, I moved it to /system/app to save space on /data partition because newer version are 5.0+ only. I was skeptical about GoogleDrive because it was multi-dex, infact apk contained classes.dex and classes2.dex: turned out I had to strip only classes.dex from the apk and leave classes2.dex inside the apk.

credits to com.modaco.odexme xda link

| improve this answer | |
  • Thanks will try when I get home and give you feedback, in the meantime +1 – xavier_fakerat Oct 13 '19 at 17:50
  • I tried it but it is not working – xavier_fakerat Oct 25 '19 at 14:56
  • For me it works, I don't even have to reboot to use the newly odexed app... I also found a static zipalign binary so I can make everything on the smartphone – Ju Tutt Nov 1 '19 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.