Question

I'm trying to understand a few things around how dex files are handled by android.

What I do know is that an APK ships a dex file, the system gets it, optimises it at install time, and stores the resulting ODEX file (optimised dex) at /data/dalvik-cache/myOdexfile and then runs the application from there.

Is that really how it works?

What happens when a dex file downloads and opens a new dex file from the internet? is that optimised as well?

Also - the system, afaik, keeps the original APK around, right? I think that is kept at /data/app/myAPK-1.apk. Is that used in any way by the system? When?

Can you somehow manually force regeneration of the odex file from the stored APK file after installation?

Was it helpful?

Solution

Yes, Android creates ODEXs from DEXs at install-time.

Yes, the APK is saved. DEX and ODEX only contain code. The APK is where all your resources and assets come from - your label, your icon, your layouts, etc.

To my understanding DEX optimization is purely an install-time process, and is not performed on any DEX that is not part of an installed APK. And since a DEX that is part of an APK cannot change without installing a new APK, there is no need to regenerate an ODEX outside of the normal install process.

OTHER TIPS

When you load a dex file dynamically, dalvik will optimize it the first time it is loaded. You have to pass a directory that you application can write to, for it to place the cached odex in, typically within the application's data dir.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top