Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting an app with android studio 'instant run' is very slow

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 ?

like image 588
mbonnin Avatar asked Apr 14 '16 21:04

mbonnin


People also ask

Why does Android Studio take so long to open?

According to Android Studio's official system requirements, it takes at minimum 3 GB RAM to run smoothly. Honestly, its a lot and I believe that is the biggest cause of being it too slow all the time. The android developers are always complaining about the speed of Android Studio and how its slow ALL THE TIME.

Does Android Studio make system slow?

Since Android Studio, by default, runs a Gradle build when you start up, it manifests as an extremely slow start-up. The problem is extremely easy to check for: While you are experiencing the symptoms of a slow Android Studio, press Ctrl - Alt - Delete and open Windows Task Manager.

Is Android Studio heavy?

In the previous versions, the android studio was more heavy software Google is updating it and making it more scalable for developers. But it is even also heavy software which will suck your computer's ram.


2 Answers

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.

like image 99
Aravind Balaji Avatar answered Nov 11 '22 20:11

Aravind Balaji


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

like image 39
James L. Avatar answered Nov 11 '22 21:11

James L.