Android Instant Run First-time takes too much time to launch app after installed

左心房为你撑大大i 提交于 2019-12-02 19:20:42

Hello I am also facing this issue when i update my Android Studio 2.0

This issue is resolved by changing minSDKVersion from 14 to 16 and change the gradle version to 2.4. This will work fine.

The question is already answered, but in my case, it is due to the strange issue with Android Studio 2.0 & 2.1. First time of launching application take longer than usual. This issue happens only in debug mode and not effect your released APK. Try creating a release build of your app and check. It should work perfectly.

It's because with Instant Run enabled, Android Studio injecting some dex files to make Instant Run function run in target device. Because of it, your application will take longer times to run than it normally does.

To check it, look at your Android Studio monitor when it starting to run your application. It will show that some dex files been loading.

The benefit of Instant Run is when you change your application and run it, sometimes it will immediately run in your device target with short delay compared without Instant Run.

But the caveat is, Instant Run still buggy and it doesn't always work.

Go to Gradle scripts -> build.gradle (Project). Inside the dependencies block, replace this line:

classpath 'com.android.tools.build:gradle:2.0.0'

with this one,

classpath 'com.android.tools.build:gradle:1.3.0'

Now, sync your project. After syncing your project, you will get some errors.

Go to gradle-wrapper.properties. Now replace this this line:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

with this one:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

Sync your project once or twice and your problem should be solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!