关于DexOpt: not all deps represented

最近在做android BSP 4.2的时候遇到一个BUG,编译user 版本的时候,系统刷进手机里面去,无限循环在开机动画,编译userdebug 刷机进去的时候发现正常,于是我先回滚到正常的版本,进系统打开adb调试,然后刷异常的版本,发现无限循环的log如下

I/dalvikvm(  823): DexOpt: not all deps represented 
 E/dalvikvm(  823): /system/framework/android.test.runner.jar odex has stale 
dependencies 

为啥会出现这个BUG呢,看了一下git,发现我新增加的 FM收音机里面有一个qcom.fmradio.jar 这个并且做了如下处理

export BOOTCLASSPATH ${BOOTCLASSPATH}:/system/framework/changhong.jar

于是我google了一下错误信息,找到了一个相关帖子

https://groups.google.com/forum/#!topic/android-porting/jgJqrZ9uGXs

The optimized DEX files have inter-file dependencies.  All .odex files
depend on the bootstrap class entries, so if you add or remove entries
from the bootclasspath you must re-run dexopt over all files.

This happens automatically on -userdebug and -eng developer builds,
but -user builds don’t have the un-optimized versions of the APKs
sitting around.  So it just falls over.

The best plan is to leave bootclasspath alone.

See also dalvik/docs/dexopt.html in the source tree.

根据这个回答,我在build/core/dex_preopt.mk  里面找到了

DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:telephony-common:voip-common:mms-common:android.policy:services:apache-xml

修改成:

DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:telephony-common:voip-common:mms-common:android.policy:services:apache-xml:changhong

注意最后面那个。

删除out/target/product/device/system,重新编译打包,刷机,正常进入系统!!

原文地址:https://www.cnblogs.com/tangdoudou/p/3503380.html