"Optimising apps" bug or feature?
When upgraded from Kitkat to Lollipop, during boot it said,
"Optimising apps, 1 of 132"
took around 20 minutes to complete. Obviously I thought that will be one-time process but it repeats randomly during boot.
Its quite annoying. When it took like 30 minutes, I decided to search for solutions. Seems like well-known issue and lot
of people such different answers like:
1,2,3 they didn't work me. Not sure, whether 4 will help or not. 5th one is seriously funny solution!
Looks like 6th (going back to Kitkat) is the only option.
But I have rooted device and thought about debugging the issue further.
Here's what I found:
1- During boot app apk files are converted into somekind of 'optimized' dex file.
2- These files are stored under /data/dalvik-cache/arm/
3- During Reboot somehow those dalvik-cache files vanished or probably /data/dalvik-cache/arm
files will be removed when system needs more space.(directory-name itself says its cache,
so its not a surprise, anyway).
4- Now step 1 gets repeated for all apk files in the mobile.
That's why I'm having this stupid 'optimising apps' message and wastes the time. Honestly, when
its obvious that you need odex files to even start 5.1 version, why its stored in cache location
instead of other locations?
Once we know the problem, there is lot of solutions/workarounds. The one trick is to ensure the file are
locked once they created in /data/dalvik-cache/arm/. This work-around took me couple of hours
I wonder why Google wasted so many hours of its Lollipop users by storing file in wrong location.
If these odex files are so critical, why not simply store them under /data/app/<package-name> instead of
using cache location like /data/dalvik-cache/arm/?
During upgrades of specific new odex can replace the old ones. And kept the booting process to avoid
"Optimising app" phase or reduce the time.
Some may call 'Optimising apps' as a feature, but for me its look like a feature with 'blocker' bug,
which wasted user time. This could have been avoided.
 Rooted app - which mimics chattr +i/-i to lock/unlock odex files.