I'm brand new to Cordova and am trying to get the splash screen working on Android. I've followed a few tutorials to the letter and have reviewed the questions here on SO but it's not working yet.
I'm using the 'Cordova CLI' approach - here is my /config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</name>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="2000" />
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<splash src="res/screen/android/splash-logo.png" density="land-hdpi"/>
<splash src="res/screen/android/splash-logo.png" density="land-ldpi"/>
<splash src="res/screen/android/splash-logo.png" density="land-mdpi"/>
<splash src="res/screen/android/splash-logo.png" density="land-xhdpi"/>
<splash src="res/screen/android/splash-logo.png" density="port-hdpi"/>
<splash src="res/screen/android/splash-logo.png" density="port-ldpi"/>
<splash src="res/screen/android/splash-logo.png" density="port-mdpi"/>
<splash src="res/screen/android/splash-logo.png" density="port-xhdpi"/>
<icon density="ldpi" src="res/screen/android/icon.png" />
<icon density="mdpi" src="res/screen/android/icon.png" />
<icon density="hdpi" src="res/screen/android/icon.png" />
<icon density="xhdpi" src="res/screen/android/icon.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
I know I should have different image sizes for each density but this is a test project so please ignore that.
I've added the cordova-plugin-splashscreen to my project.
cordova plugin add cordova-plugin-splashscreen
The splashscreen is still not being displayed - instead a blackscreen turns up when the app runs on the emulator. After a couple of seconds, the blackscreen goes away and the default 'device-ready' Cordova screen appears.
I've done everything suggested in other places - can you guys spot what's wrong?
FYI I was looking at the /plataforms directory and it seems things are correctly set.
The snippet below is from /platforms/android/res/xml/config.xml:
<splash density="land-hdpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="land-ldpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="land-mdpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="land-xhdpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="port-hdpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="port-ldpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="port-mdpi" src="res/drawable-land-xhdpi/screen.png" />
<splash density="port-xhdpi" src="res/drawable-land-xhdpi/screen.png" />
<icon density="ldpi" src="res/screen/android/icon.png" />
<icon density="mdpi" src="res/screen/android/icon.png" />
<icon density="hdpi" src="res/screen/android/icon.png" />
<icon density="xhdpi" src="res/screen/android/icon.png" />
There are screen.png files under every directory listed above - so it seems Cordova is doing its work correctly.
Main activity:
package com.example.hello;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
cordova plugins
output. Try tocordova plugin rm splashscreen && cordova plugin add https://github.com/apache/cordova-plugin-splashscreen
as @jaydroider suggested. Alternatively try to add<preference name="FadeSplashScreenDuration" value="500"/>
toconfig.xml
. – daserge