[Solved] An error occurred when installing the apk, Failure [INSTALL_FAILED_DEXOPT]

After compiling the apk in the android4.0 source code, when installing with adb install (or adb install -r reinstall), an error [INSTALL_FAILED_DEXOPT] is reported.

[email protected] :~$ adb install workspace/out/target/product/generic/system/app/xxx.apk
2820 KB/s (225970 bytes in 0.078s)
pkg: /data/local/tmp/xxx.apk


[email protected] :~$ adb install -r workspace/out/target/product/generic/system/app/xxx.apk
2768 KB/s (225970 bytes in 0.079s)
pkg: /data/local/tmp/xxx.apk

This is because the apk under system\app is optimized, and the dex file will not be packaged into the apk. The dex file will be optimized to generate an odex file .

The following are the two files .odex and .apk generated under workspace/out/target/product/generic/system/app/ after the program is compiled

Install: out/target/product/generic/system/app/xxx.odex
Install: out/target/product/generic/system/app/xxx.apk

When installing the apk in this way, the dex file will be missing, resulting in an error [INSTALL_FAILED_DEXOPT].


Find the unoptimized apk, that is , find the corresponding APP under out/target/product/generic/obj/APPS/ :

[email protected]:~$ adb install workspace/out/target/product/generic/obj/APPS/xxx_intermediates/package.apk.unaligned
2400 KB/s (331697 bytes in 0.134s)
pkg: /data/local/tmp/package.apk.unaligned
[email protected]:~$

If you have already installed the program, you can reinstall it:

[email protected]:~$ adb install -r workspace/out/target/product/generic/obj/APPS/xxx_intermediates/package.apk.unaligned
2873 KB/s (331689 bytes in 0.112s)
pkg: /data/local/tmp/package.apk.unaligned


This installs ok!

Similar Posts: