Apache Cordova splash screens not showing in Android

后端 未结 9 1412
一生所求
一生所求 2020-12-05 10:24

I am running Apache Cordova 3.6.3-0.2.13. And I try to get the splash screens working. I have followed the documentation on http://cordova.apache.org/docs/en/3.6.0/config_re

相关标签:
9条回答
  • 2020-12-05 10:30

    2019 February end:

    Only two things I did and it worked:

    • Install plugin:

      cordova plugin add cordova-plugin-splashscreen

    • Add below to config.xml, have corresponding images

    (1st splash line is a generic screen size, if you want)

    <platform name="android">
        <splash src="res/screen/android/splash-2732x2732.png" />
    
        <splash density="land-ldpi" src="res/screen/android/splash-land-320x200-ldpi.png" />
        <splash density="land-mdpi" src="res/screen/android/splash-land-480x320-mdpi.png" />
        <splash density="land-hdpi" src="res/screen/android/splash-land-800x480-hdpi.png" />
        <splash density="land-xhdpi" src="res/screen/android/splash-land-1280x720-xhdpi.png" />
        <splash density="land-xxhdpi" src="res/screen/android/splash-land-1600x960-xxhdpi.png" />
        <splash density="land-xxxhdpi" src="res/screen/android/splash-land-1920x1280-xxxhdpi.png" />
        <splash density="port-ldpi" src="res/screen/android/splash-port-200x320-ldpi.png" />
        <splash density="port-mdpi" src="res/screen/android/splash-port-320x480-mdpi.png" />
        <splash density="port-hdpi" src="res/screen/android/splash-port-480x800-hdpi.png" />
        <splash density="port-xhdpi" src="res/screen/android/splash-port-720x1280-xhdpi.png" />
        <splash density="port-xxhdpi" src="res/screen/android/splash-port-960x1600-xxhdpi.png" />
        <splash density="port-xxxhdpi" src="res/screen/android/splash-port-1280x1920-xxxhdpi.png" />
    </platform>
    
    0 讨论(0)
  • 2020-12-05 10:35

    I had to install the splash screen plugin to make it work

    cordova plugin add cordova-plugin-splashscreen

    as well as adding

    <preference name="SplashScreen" value="screen" />

    <preference name="SplashScreenDelay" value="2000" />

    0 讨论(0)
  • 2020-12-05 10:35

    After carefully following the PhoneGap CLI splash screen instructions, my Android splash screen was still not showing up. I then looked at build.gradle under platforms/android and noticed that changes I made to the defaultConfig block were causing changes to AndroidManifest.xml that ultimately prevented the splash screen from working. Below is the defaultConfig block I was using:

    defaultConfig {
        applicationId "com.leadingedje"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode getAppVersionCode()
        versionName getAppVersionName()
    }
    

    When I removed this block from build.gradle, the splash screen started working again.

    0 讨论(0)
  • 2020-12-05 10:36

    I solved the problem by adding default splash tag

    Add this to config.xml in the root destination or in www/config.xml

    <gap:splash src="splash.png" />
    
    0 讨论(0)
  • 2020-12-05 10:38

    For new comers and those who are still facing this issue

    1) Add Splash screen preference in config.xml

    <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 in config.xml

        <!-- 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) Finally Add this class into your android project structure under org.apache.cordova.splashscreen package

    or

    install it as Cordova plugin.

    0 讨论(0)
  • 2020-12-05 10:42

    I had a similar issue on android, I put the Splash Screen Directly into res/drawable-hdpi and got the following error during cordova build.

    res/drawable-hdpi-v4/DocBackground.png: Invalid file name: must contain only [a-z0-9_.]
    

    When I de-capitalised the file name, in ~project/icons, cordova build copied them to the res/drawable folder & splash screen worked.

    0 讨论(0)
提交回复
热议问题