17

I just enabled instant run for my project. Building and uploading is faster but my app startup time has increased from a few hundreds of milliseconds to a few seconds.

I'm generally happy with that compromise. I just wanted to know if I was the only one noticing this and if there can be any chance to optimize that too ?

mbonnin
  • 6,893
  • 3
  • 39
  • 55
  • I noticed an increase in time as well, I [turned off Instant Run](http://stackoverflow.com/questions/35168753/instant-run-in-android-studio-2-0-how-to-turn-off). – buczek Apr 14 '16 at 21:07
  • 1
    have also noticed an increase in app start up time. mine went from 3 seconds to 35 seconds. – Caren May 03 '16 at 21:55
  • I believe this is an issue with the SDKs you have installed, if you have any. Instant Run doesn't seem to play well with some SDKs in applications. Try simply removing the start lines for those libraries/SDKs in your application onCreate and see if it makes a difference in speed. – Vic Vuci May 31 '16 at 20:43
  • please check [this answer](http://stackoverflow.com/a/37207831/2826147) – Amit Vaghela Jun 05 '16 at 11:19

2 Answers2

1

This is a known bug in Android Studio I've been facing this problem for a long time and I came across a Reddit thread that explains the actual cause of the problem...

Here's the link to the Thread:

https://m.reddit.com/r/androiddev/comments/4m2v25/instant_run_causing_incredibly_long_app_start/

Solution

Until the problem has been resolved perform any of the following : 1. Turn off Instant Run 2. Revert back to version 2.8 of Gradle

Things you should do: 1. Wait until the problem is fixed


Sorry, this is a known issue right now. We are working on improving it in 2.3. The reason this happens is that: Initially, we split all your code into multiple dex files, and put them all inside a instant-run.zip file After the first install, we unzip that file and add all those classes to the classpath. This is the step that takes time, you see a white screen. In the worst case, you may even get an ANR. We split it up so that on subsequent updates, we only send out the dex files that have changed. In Android N, we have some more platform support via split APKs, which we leverage and should be faster.

Aravind Balaji
  • 57
  • 2
  • 10
1

some good news for this thread. We have just release Android Studio 2.3 Canary 1, and it should completely fix the startup performance issue for Instant Run.

Please try it out and let us know what you think! Download link: http://tools.android.com/download/studio/builds/android-studio-2-3-canary-1

James L.
  • 181
  • 5