Search code examples
androidandroid-studio-2.0android-gradle-2.0

Time taken on first run with AS 2.0 and gradle 2.0


Recently i have upgraded Android Studio from 1.5 to 2.0.

With that i am using gradle 2.0.0

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

But there seems some issue with it, whenever i am running my app for first time, it is showing while/black screen for 10-15 seconds.

There is nothing i am doing on applicationClass or launcher activity, but then also it is taking this much time.

I don't know whether it is issue with AS 2.0 or Gradle 2.0.0. Strange thing is that it is working properly on emulator, it is just taking time on device. So there might be possibility of device RAM or processing issues, but i have checked it in 10-12 devices and all devices have same issue.

Problem arise when i am running my application for first time, then after it is working as usual and loads launcher activity within fraction of seconds.

Can anyone please help me in this?


Solution

  • there seems some issue with it, whenever i am running my app for first time, it is showing while/black screen for 10-15 seconds.

    I guess you have issue of Cold Start in your application.

    Cold Start :

    When a user launches an application, Android creates a new process that, during it charge, shows a black/white screen which is built with the application theme, or the theme of the activity that is the entry point.

    This load can be increased if our application is complex and overwrites the application object, which is normally used to initialize the analytics, error reporters, etc.

    Solution :

    1. Specify android:windowBackground in your application theme.
    2. Add Splash screen to your app.

    For detailed information please check, http://saulmm.github.io/avoding-android-cold-starts

    Thanks.