Skip to content Skip to sidebar Skip to footer

Splash Screens Not Working In Phonegap Build

I can't get splash screens working at all, in either Android or iOS. I'm using PhoneGap Build and I've set config.xml like this, which is for v3.0.0 now.

Solution 1:

For iOS

You will need to copy your splash screen images into the platform directory, they will not automatically be copied from www/res/.

For iOS this will be:

platform/ios/[name of your project]/splash/

These should be the PhoenGap default splashscreens.

For Android

The documentation seems a bit lacking for this. But you need to create the relevant folders in your platform/android/res folder. These should be:

  • platform/android/res/drawable-land-hdpi
  • platform/android/res/drawable-land-ldpi
  • platform/android/res/drawable-land-mdpi
  • platform/android/res/drawable-land-xhdpi
  • platform/android/res/drawable-land-xxhdpi
  • platform/android/res/drawable-port-hdpi
  • platform/android/res/drawable-port-ldpi
  • platform/android/res/drawable-port-mdpi
  • platform/android/res/drawable-port-xhdpi
  • platform/android/res/drawable-port-xxhdpi

Inside those folders you will need to upload your splash screen, make sure it is called splash.png, otherwise it will not be picked up by the application.

One final and important step, you need to add the following line to your main Activity file, this can be found within your android project folder and will be named the same name as your application. The file extends the Cordova default activity file which explains about extending and adding the splash screen. The file will be:

platforms/android/src/com/[your app name]/[your app name].java

It should look something like this:

package com.your.project;

import android.os.Bundle;
import org.apache.cordova.*;

publicclassYourProjectextendsCordovaActivity 
{
    @OverridepublicvoidonCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xmlsuper.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}

But needs to be changed to:

package com.your.project;

import android.os.Bundle;
import org.apache.cordova.*;

publicclassYourProjectextendsCordovaActivity 
{
    @OverridepublicvoidonCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xmlsuper.setIntegerProperty("splashscreen", R.drawable.splash);
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}

Notice the additional line added:

super.setIntegerProperty("splashscreen", R.drawable.splash);

Official documentation is here, http://docs.phonegap.com/en/3.3.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens, but it doesn't seem to cover all the necessary steps.

Solution 2:

Based on your comment below your question, here is what I recommend.

  1. Create a small black square and save the image as splash.png
  2. Place splash.png in your root folder (the same location as your index.html)
  3. Use this in your config.xml <gap:splash src="splash.png" />

You will now have a solid black splash screen that will look like there is no splash screen.

Solution 3:

So this issues seems to be fixed now.

As you can see from my initial question I was coding the config wrong. The PGB versions selection code should not be "xmlns:gap = "http://phonegap.com/ns/3.0.0" but:

<preferencename="phonegap-version"value="3.0.0" />

I do blame PGB a bit for this as the docs weren't clear (though they are improving).

Anyway - get your splash screens working use the info here.

I'm now using PGB 3.3.0 and it seems all fine.

Post a Comment for "Splash Screens Not Working In Phonegap Build"