31

Since upgrading to Android Studio 2.0 (stable) I've noticed an issue that wasn't there in the previous version of Android Studio 1.5 I had installed.

I'm working on a current project, which I would build (debug version) and run, both on a real device, and an emulator, I was doing this in Android Studio 1.5.

Since upgrading Android Studio 2.0 whenever I make a build (debug) the same project/app and run it I have noticed that I get a pause on the device, or emulator. I get a white screen for a couple seconds before the app opens, which I didn't have before in AS 1.5, the app would open straight away, no pause, no white screen - this happens whether the phone is plugged in using ADB, or unplugged. If the App is still in phones memory it opens straight away, but if phone is restarted I get the pause, and white screen when the app is opened.

Is their a solution to this? Has anyone else experienced this? I may be a bit premature with this as I haven't done a release build yet, however this seems like a strange issue - if it is an issue!

Edit:

I am using Instant Run, however this happens whether a device is plugged in or not. Would Instant Run make a difference to its execution if it wasn't plugged in?

Update:

As below answer turning off 'Instant Run' options in Android Studio 2.0 cures the problem. Interestingly however, comments suggest that when using Instant Run APK sizes are smaller. What does this mean? Could it be that Instant Run uses the older Dalvik/JIT compiler rather than ART? This could explain the Apk size difference, and the lag (Dalvik compiles on the fly - JIT). Also ART would need to install/compile each time the app was Run, meaning its Apk size would be larger, and slower to execute, as is the case.

Hopefully someone with more experience and knowledge maybe able to confirm or debunk this..

Mark
  • 9,604
  • 5
  • 36
  • 64
  • 1
    does this happen with real device also?? – Vivek Mishra Apr 12 '16 at 13:47
  • @VivekMishra yes .. both. – Mark Apr 12 '16 at 13:49
  • I also see this and think it is coming from instant-run – ligi Apr 12 '16 at 13:49
  • But this happens whether its plugged in or not? Would Instant Run make a difference to its execution if it wasn't plugged in? – Mark Apr 12 '16 at 13:50
  • Well I noticed it today but it's happening with mine apps too. – Vivek Mishra Apr 12 '16 at 13:50
  • Yeah it happens real devices too.In instant run or first run i see white screen for a couple secs. – Yasin Kaçmaz Apr 12 '16 at 13:50
  • I noticed that this white screen is coming in almost all apps on my device – Vivek Mishra Apr 12 '16 at 13:55
  • @VivekMishra - I have only noticed this on my own projects/apps since building them in Android Studio 2.0 - Instant Run does seem like an obvious culprit, but seems weird that it would persist with a device not plugged in, so this leads me to think it isn't this. – Mark Apr 12 '16 at 13:58
  • `@null` try adding this in your theme and add this theme to your launcher activity – Vivek Mishra Apr 12 '16 at 14:10
  • @VivekMishra I'll have a try, although this feels like a workaround, rather than getting to the root cause - as I say - I haven't changed the code, just the version of Android Studio - when I can get to my computer I might have a look at the traceview, but again, the code hasn't changed.. – Mark Apr 12 '16 at 14:20
  • Happening with me too.I updated today , and i am getting a 4 second pause with white screen before splash.Also crashes on some versions – Ajji Apr 12 '16 at 21:10
  • Instant run does simply update the dex with like patches, these would persist, even after unplugged. It installs once and patches the dex files. But, it shouldn't do it the first time regardless. – Tatarize Apr 12 '16 at 23:41
  • 2
    @Tatarize I can confirm that when I disable Instant Run the issue no longer occurs (as below answer) - why? I have no idea. As instant run is a new feature this 'lag' may disappear, depending on the circumstances of why it happening in the first place. – Mark Apr 13 '16 at 22:31

2 Answers2

36

Check image for reference Turn off Instant Run in Settings. File>Settings>Build,Deployment>Instant Run Deselect all options shown there.

Now white screen problem is solved.

In android studio 2.0,My APK size was 16 MB while using Instant Run. Without using Instant Run it became 27 MB. While in 1.5 .. the size was 27 MB.

Instant Run is the culprit.

  • White screen Issue/ Instant Run is only for Debug builds .. Issue will not affect release builds.
Victor
  • 4,171
  • 1
  • 29
  • 37
  • thanks, I'll have uncheck those settings when I get back to my computer - if it works I'll mark as accepted answer. – Mark Apr 13 '16 at 11:42
  • This size thing happened with me. My file size was 7.5MB on version 1.5.1 and now its 3.3MB , giving crashes and white screen at start up. – Ajji Apr 14 '16 at 19:25
  • I have also experienced this issue and in my case the first run time improves significaltly using Instant Run if I set the `minSdkVersion` to `21` as stated here: http://developer.android.com/intl/es/tools/building/building-studio.html#instant-run – antonio Apr 28 '16 at 09:27
  • 2
    still not resolved in my case. I have deselected all options under instant run (Android Studio 2.1.1). – jay Jul 31 '16 at 16:40
  • This solution reduced white screen delay but didn't eliminate it and I am still getting "ClassLoader referenced unknown path" error :( – akshay7692 Sep 26 '16 at 13:20
-5

No need at all, If you try to deselect all option in Settings. File > Settings > Build, Deployment > Instant Run, your app will get into large size build on the device. (On your device goto Settings-->Application-->See your app in a big size than normal. In this case to avoid white screen when running your app, in AndroidMenifest.xml, at first activity, add:

"android:theme="@android:style/Theme.Translucent.NoTitleBar"

For example:

       <activity
           android:name=".WelcomeScreen"
           android:label="@string/app_name"
           android:theme="@android:style/Theme.Translucent.NoTitleBar" >
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       <activity android:name=".SplashActivity" />

In this example, WelcomeScreen is my First start Activity.

Goodluck to you!

Mark
  • 9,604
  • 5
  • 36
  • 64
  • The problem is to do with Instant Run in this particular instance, your above solution in not related to this issue – Mark Aug 03 '16 at 08:35