Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app slow initial startup time

After I started using UI elements from the android support design library the app initial load time has become really slow (about 8 seconds!) and I am really not sure why.

I ran method tracking during most of the startup (It takes time for android studio to start running the cpu monitor) and found it spend 4 seconds on: dalvik.system.DexFile.openDexFile, Im not sure why this is taking so long.

Any ideas? (I didnt add any code since there is a lot of code in my app and I dont know where the problem is coming from...)

like image 714
TomerZ Avatar asked Jul 20 '16 07:07

TomerZ


1 Answers

I experienced an increase in speed when building the release app instead of the debug version that I normaly run.

I'm not sure why it works, but I guess it has to be because of the way the compiler links the ext libs into the apk. I once saw an interview with Chet Haase who is one of the devs on the android ui platform, who explained how they were trying to show the first activity on the app as quickly as possible to avoid dull splash screen. Maybe that feature is somehow enabled in the release build process.

EDIT: The correct answer is written below by @Embydextrous. It is cause by the dexing of the app in debug mode.

like image 151
miqueloi Avatar answered Oct 03 '22 18:10

miqueloi