Skip to content

Instantly share code, notes, and snippets.

@jieyu
Last active October 16, 2017 10:16
Show Gist options
  • Save jieyu/4518166 to your computer and use it in GitHub Desktop.
Save jieyu/4518166 to your computer and use it in GitHub Desktop.
Solving the unbootable Android problem caused by stale ODEX dependencies.

Stale ODEX dependencies cause unbootable Android

This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).

Suppose that you want to customiz your android system, you may want to modify /system/framework/framework.jar (source files are in the directory frameworks/base). During development, let's assume that you just did a full build, and you decide to make some changes to some source files. After that, you want to build again. Ideally, the building system can correctly re-build everything that is dependent on the changes you just made. However, seems that the android building system does not do it properly. You will get an unbootable image caused by mismatched dex signature. If you check the log when system boots, you will see an error message like the following:

07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/apache-xml.jar odex has stale dependencies

The reason is that many system apks which was optimized before (ODEX) need to be rebuilt because they are dependent on system framework jar (but they are not). This causes odex mismatch error at bootup which leads to unbootable android in the worst case.

To solve this problem, you have two options:

  1. Set variable WITH_DEXPREOPT to false in build/target/board/generic/BoardConfig.mk

  2. Add WITH_DEXPREOPT=false when make. It's like the following:

    make -j4 WITH_DEXPREOPT=false

@wushenwu
Copy link

that's great, thanks for the sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment