Android create odex files thru build system
May 16, 2011 12:13:34 Last update: May 16, 2011 12:17:17
By Android documentation, odex files are "Optimized DEX" files, which can be created in at least three different ways:
The
So how is odex file generated at build time? Prior to Oct. 2010, it was generated by a tool called
- The VM does it "just in time". The output goes into a special
dalvik-cachedirectory. This works on the desktop and engineering-only device builds where the permissions on thedalvik-cachedirectory are not restricted. On production devices, this is not allowed. - The system installer does it when an application is first added. It has the privileges required to write to
dalvik-cache. - The build system does it ahead of time. The relevant
jar/apkfiles are present, but theclasses.dexis stripped out. The optimized DEX is stored next to the original zip archive, not indalvik-cache, and is part of the system image.
The
dalvik-cache directory is more accurately $ANDROID_DATA/data/dalvik-cache (/data/dalvik-cache for the emulator).
So how is odex file generated at build time? Prior to Oct. 2010, it was generated by a tool called
dexpreopt under the platform/build.git project via dexopt-wrapper, which depends on the emulator. After that, it is generated on the host side with a switch to the make command (dexpreopt was removed from source tree):
$ make WITH_DEXPREOPT=true