thedarkpassenger
thedarkpassenger

Reputation: 7358

Launching application in Debug mode takes a lot of time for the first time

When I install my application in debug mode, and open it for the first time it takes a lot of time (nearly 20-30 seconds). I guess it is due to multi dex enabled. It is happening after updating my Android Studio to version 2.0 and upgrding the android gradle plugin to version '2.0.0'. What is the reason for this behaviour? Is somebody else also facing similar issues?

I have been testing on Moto G3 with android marshmallow.

Upvotes: 2

Views: 1382

Answers (4)

Abdul Rizwan
Abdul Rizwan

Reputation: 4108

Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run

enter image description here

I was also facing the same problem and finally i fixed this.
note:
1) before generating an apk file unchecked all these option to resolve delay issue from your production build.

2) while you are developing or adding new features then keep it as default setting(instant run) to make development faster.

I hope this will resolve your issue.

Upvotes: 0

Michele La Ferla
Michele La Ferla

Reputation: 6884

This happens most of the time because of the prolonged time needed to build the solution. The time needed to build a solution is mostly dependent on the number of libraries you are referencing, and the complexity of your code.

Remember that it is the first time you are building the app, so Android Studio has no record of the solution in its cache, hence it has to build everything from scratch.

Android Studio 2.0 also has the instant run feature, so it takes longer to run the first time, so that you can then debug instantly in the subsequent runs.

Hope this helps :)

Upvotes: 1

Jerry
Jerry

Reputation: 966

There is an issue with multidex and API level 21+, relative to Instant Run. The documentation only mentions it without explanation though.

Instant Run

Upvotes: 0

ARP
ARP

Reputation: 539

I think is because of the new Instant Run feature. The first time takes a lot of time, but after that new changes are visible almost at the same time in your device. In any case you can disable Instant Run in: File->Settings->Build,Execution,Deployment->Instant Run

Upvotes: 0

Related Questions