Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova - white screen after splash, no exceptions in console

I've been away from my Cordova app for a bit, but just did a fresh clone yesterday and noticed that it's got the "white screen of death" symptoms -- the splash screen displays, the program loads... and then I just get a blank screen. Some more details:

  • CLI: Cordova 6.1.1, android 5.1.1, ios 4.1.1
  • I'm not using any special plugins to display a splash screen -- just <splash> elements in my config.xml file.
  • This is happening in both iOS and Android, both on local builds and using PhoneGap Build (i.e., debug and release).
  • There are no exceptions of missing resources in the console, either in iOS (using Safari's dev tools) or Android (using Chrome's dev tools).
  • I've done a diff with my last known working build, and there's really nothing that pops out. I saw an undefined Underscore reference, but I backed that change out and it didn't resolve anything -- I think I'd see the exception in the console, anyway.

Has Cordova / PhoneGap done something recently that might be causing this? Any ideas on how to isolate this one? I'm really stumped.

like image 833
eb1 Avatar asked Apr 11 '16 16:04

eb1


3 Answers

Well that was ugly. It turned out that there was an exception being thrown, it was just being thrown too early for the browser dev tools to pick it up (Safari, Chrome for iOS and Android, respectively). The exception did show up when I ran things through the browser target (cordova platform add browser, etc.) So that browser platform is useful for something I guess. :-)

In my case, the cordova-sqlite-storage plugin had made a breaking API change that broke the code when I updated everything. The solution was to pin the plugin to an earlier version in the config.xml file.

So, lessons learned:

  • If you suspect there's an exception being thrown during startup, you can use the browser platform to track it down.
  • Pin your plugins to a specific version using the spec parameter in the config.xml. This will save you some heartache in the future.
  • [another option from @jcesarmobile, below] hitting refresh in the browser dev tools will also kick out the exception. Nice!

I'll be going back in to the config.xml and pinning the other items -- and doing some cleanup as suggested above. Thanks again, everyone.

like image 169
eb1 Avatar answered Nov 17 '22 00:11

eb1


I manged to run your app this are the steps I followed.

1) First you need to declare Splash screen preference along with splash screen plugin location in your config.xml. This is what I think you are missing

<preference
    name="SplashScreen"
    value="screen" />
<preference
    name="AutoHideSplashScreen"
    value="true" />
<preference
    name="SplashScreenDelay"
    value="5000" />

<feature name="SplashScreen" >
    <param
        name="android-package"
        value="org.apache.cordova.splashscreen.SplashScreen" />

    <param
        name="onload"
        value="true" />
</feature>

2) Declare your splash screens images in config.xml ,which you have already done.

I suggest you to keep images in default density folders of android project (ldpi,mdpi,hdpi,xhdpi etc) instead of screen/android folder as it will simplifiy your project structure.

    <!-- you can use any density that exists in the Android project -->
    <splash
        density="land-hdpi"
        src="res/drawable-land-hdpi/splash.png" />
    <splash
        density="land-ldpi"
        src="res/drawable-land-ldpi/splash.png" />
    <splash
        density="land-mdpi"
        src="res/drawable-land-mdpi/splash.png" />
    <splash
        density="land-xhdpi"
        src="res/drawable-land-xhdpi/splash.png" />
    <splash
        density="port-hdpi"
        src="res/drawable-hdpi/splash.png" />
    <splash
        density="port-ldpi"
        src="res/drawable-ldpi/splash.png" />
    <splash
        density="port-mdpi"
        src="res/drawable-mdpi/splash.png" />
    <splash
        density="port-xhdpi"
        src="res/drawable-xhdpi/splash.png" />
</platform>

3) Add Splash screen plugin class into your android project structure under org.apache.cordova.splashscreen package or install splash screen Cordova plugin

https://cordova.apache.org/docs/en/3.1.0/cordova/splashscreen/splashscreen.html

4) Final and most important step you must have cordova.js in your www folder

Cordova.js in assets

And after that I was able to run your web app

enter image description here

I am android developer I guess something similar you might need to do for iOS

like image 5
Hitesh Sahu Avatar answered Nov 16 '22 23:11

Hitesh Sahu


The only fix that worked for me was found here: http://www.codingandclimbing.co.uk/blog/ionic-2-fix-splash-screen-white-screen-issue-14

basically edit your config.xml file. The splashscreen setup should look like this:

<preference name="ShowSplashScreen" value="true"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="30000"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="SplashShowOnlyFirstTime" value="false"/>
<preference name="FadeSplashScreen" value="false"/>
<feature name="SplashScreen">
    <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
</feature>
like image 2
Gio Avatar answered Nov 17 '22 01:11

Gio