安装apk时出现错误Failure [INSTALL_FAILED_DEXOPT]问题解决的方法

在android4.0源码里面编译出来apk后,用adb install (或adb install -r 重装)安装时,报错[INSTALL_FAILED_DEXOPT]。

xu@xu-PC :~$ 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
Failure [INSTALL_FAILED_DEXOPT]
或者

xu@xu-PC :~$ 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
Failure [INSTALL_FAILED_DEXOPT]

这是因为在system\app下面的apk是经过优化的,而dex文件不会打包到apk中,dex文件会被优化后,生成odex文件

下面就是程序经编译之后,在workspace/out/target/product/generic/system/app/下生成的.odex和.apk两个文件

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

这样安装apk时,就会缺少dex文件,导致报错[INSTALL_FAILED_DEXOPT]。

-->解决办法:

找到未优化过的apk,即在out/target/product/generic/obj/APPS/下找到对应的APP

xu@xu-PC:~$ 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
Success
xu@xu-PC:~$

如果已经安装了该程序,可以重装一下:

xu@xu-PC:~$ 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
Success

 

这样就安装ok了!


    你可能感兴趣的:(安装apk时出现错误Failure [INSTALL_FAILED_DEXOPT]问题解决的方法)