1

According to one of great answers to this question, Android has to decompress each application's APK and OBB files before the app can be run.

Is this decompression performed each and every time an app is run, assuming it has been pushed out of Android's process cache?

1
  • run adb logcat -v long and when your phone boots, after the boot image is gone, and home screen appears, or right before that... you will see a ton of very fast info go by which all have sound file types like this vorbis/obb or whatever data type is being decompressed. It probably lasts about a minute, maybe less.
    – SudoSURoot
    May 10, 2015 at 1:13

1 Answer 1

1

Yes, and no. Android apps are not decompressed into the file system when it needs to run. Instead, they are selectively decompressed and read into memory/ram by the Dalvik virtual machine. This decompression is a very simple, quick, non-processor-intensive process, so it does not add any real overhead to the system. On first install, there is some optimization by the Dalvik VM, mainly linking to native libraries on the Android system to the internal APK libraries, and this is saved into the Dalvik-cache as an optimized dex file (.odex)

[Side note, this is why the first boot of a phone takes longer, as the system has to create odex files for any app that does not have an odex file. System Apps are typically made to have an odex by the manufacturer]

An APK has a predefined structure, including file lists, resources, assets, libraries, dex (Java Class files converted into Dalvik Executable Format) etc. The system decompresses and reads these files into memory, and follows the code inside. That code tells it when to decompress and load the other files.

It never hits the hard drive, goes right into memory.

3
  • You might want to add information here about any changes ART brought into this.
    – Joe Sewell
    May 11, 2015 at 16:44
  • I'm not sure ART does make any changes to this. Maybe the odex part, but the general apk stays the same.
    – cde
    May 11, 2015 at 16:48
  • I use an ancient desktop that doesn't support the Android development kit, so I don't have the info. I know Dalvik did a JIT compile of things, while ART pre-compiles the VM bytecode into native instructions pretty much at install and on restart if necessary. Whether that goes into the .odex file or not, though, I'm not sure.
    – Joe Sewell
    May 11, 2015 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .