Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 719
Ravi Avatar asked Apr 21 '16 04:04

Ravi


People also ask

How much time does Gradle build takes?

In your build. gradle, if you have minifyEnabled for debug, remove it. I had it in my project and it took ~2-3 minutes to build.

How long does gradle project sync take?

One bit of a downside is that it takes roughly 3 minutes to re-sync when we "Import Gradle Project". There is no feedback to tell us what it is doing, so it's hard to know what we might tweak to see if we can get it faster. We are on the latest - 2019.2. x.


1 Answers

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.

like image 175
AndiGeeky Avatar answered Sep 21 '22 15:09

AndiGeeky