【问题标题】:Phonegap / ionic app splash screen are not shown未显示 Phonegap / ionic 应用程序启动画面
【发布时间】:2015-07-22 08:31:08
【问题描述】:

我一直在尝试为我的 Ionic 应用程序添加启动画面。我们正在使用 Phonegap 3.7.0 将其部署到 ios 和 android 设备,但似乎没有任何效果。奇怪的是,当我在模拟器中运行应用程序时,会显示启动画面(例如:ionic emulate android)

使用此配置,图标可以正常工作,但闪屏无法正常工作。它显示一个空白屏幕,甚至不是科尔多瓦默认的启动画面。

我的 config.xml :

<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="ShowSplashScreenSpinner" value="true"/>
<preference name="SplashScreenDelay" value="5000"/>
<preference name="SplashScreen" value="screen"/>

<gap:plugin name="org.apache.cordova.device"/>
<gap:plugin name="org.apache.cordova.network-information"/>
<gap:plugin name="org.apache.cordova.inappbrowser"/>
<gap:plugin name="uk.co.whiteoctober.cordova.appversion" version="0.1.4"/>
<gap:plugin name="org.apache.cordova.statusbar" version="0.1.4" source="pgb"/>
<gap:plugin name="com.ionic.keyboard" version="1.0.3" source="pgb"/>
<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.3.8" source="pgb"/>
<gap:plugin name="fi.avaus.cordova.geolocation"/>
<gap:plugin name="org.apache.cordova.splashscreen" version="0.3.4"/>
<platform name="ios">
  <icon src="resources/ios/icon/icon.png" gap:platform="ios" width="57" height="57"/>
  <icon src="resources/ios/icon/icon@2x.png" gap:platform="ios" width="114" height="114"/>
  <icon src="resources/ios/icon/icon-40.png" gap:platform="ios" width="40" height="40"/>
  <icon src="resources/ios/icon/icon-40@2x.png" gap:platform="ios" width="80" height="80"/>
  <icon src="resources/ios/icon/icon-50.png" gap:platform="ios" width="50" height="50"/>
  <icon src="resources/ios/icon/icon-50@2x.png" gap:platform="ios" width="100" height="100"/>
  <icon src="resources/ios/icon/icon-60.png" gap:platform="ios" width="60" height="60"/>
  <icon src="resources/ios/icon/icon-60@2x.png" gap:platform="ios" width="120" height="120"/>
  <icon src="resources/ios/icon/icon-60@3x.png" gap:platform="ios" width="180" height="180"/>
  <icon src="resources/ios/icon/icon-72.png" gap:platform="ios" width="72" height="72"/>
  <icon src="resources/ios/icon/icon-72@2x.png" gap:platform="ios" width="144" height="144"/>
  <icon src="resources/ios/icon/icon-76.png" gap:platform="ios" width="76" height="76"/>
  <icon src="resources/ios/icon/icon-76@2x.png" gap:platform="ios" width="152" height="152"/>
  <icon src="resources/ios/icon/icon-small.png" gap:platform="ios" width="29" height="29"/>
  <icon src="resources/ios/icon/icon-small@2x.png" gap:platform="ios" width="58" height="58"/>
  <icon src="resources/ios/icon/icon-small@3x.png" gap:platform="ios" width="87" height="87"/>
  <gap:splash src="resources/ios/splash/Default-568h@2x~iphone.png" gap:platform="ios" width="640" height="1136"/>
  <gap:splash src="resources/ios/splash/Default-667h.png" gap:platform="ios" width="750" height="1334"/>
  <gap:splash src="resources/ios/splash/Default-736h.png" gap:platform="ios" width="1242" height="2208"/>
  <gap:splash src="resources/ios/splash/Default-Landscape-736h.png" gap:platform="ios" width="2208" height="1242"/>
  <gap:splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" gap:platform="ios" width="2048" height="1536"/>
  <gap:splash src="resources/ios/splash/Default-Landscape~ipad.png" gap:platform="ios" width="1024" height="768"/>
  <gap:splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" gap:platform="ios" width="1536" height="2048"/>
  <gap:splash src="resources/ios/splash/Default-Portrait~ipad.png" gap:platform="ios" width="768" height="1024"/>
  <gap:splash src="resources/ios/splash/Default@2x~iphone.png" gap:platform="ios" width="640" height="960"/>
  <gap:splash src="resources/ios/splash/Default~iphone.png" gap:platform="ios" width="320" height="480"/>
</platform>
<platform name="android">
  <icon src="resources/android/icon/drawable-ldpi-icon.png" gap:platform="android" density="ldpi"/>
  <icon src="resources/android/icon/drawable-mdpi-icon.png" gap:platform="android" density="mdpi"/>
  <icon src="resources/android/icon/drawable-hdpi-icon.png" gap:platform="android" density="hdpi"/>
  <icon src="resources/android/icon/drawable-xhdpi-icon.png" gap:platform="android" density="xhdpi"/>
  <icon src="resources/android/icon/drawable-xxhdpi-icon.png" gap:platform="android" density="xxhdpi"/>
  <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" gap:platform="android" density="xxxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-ldpi-screen.png" gap:platform="android" density="land-ldpi"/>
  <gap:splash src="resources/android/splash/drawable-land-mdpi-screen.png" gap:platform="android" density="land-mdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-hdpi-screen.png" gap:platform="android" density="land-hdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xhdpi-screen.png" gap:platform="android" density="land-xhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" gap:platform="android" density="land-xxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" gap:platform="android" density="land-xxxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-ldpi-screen.png" gap:platform="android" density="port-ldpi"/>
  <gap:splash src="resources/android/splash/drawable-port-mdpi-screen.png" gap:platform="android" density="port-mdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-hdpi-screen.png" gap:platform="android" density="port-hdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xhdpi-screen.png" gap:platform="android" density="port-xhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" gap:platform="android" density="port-xxhdpi"/>
  <gap:splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" gap:platform="android" density="port-xxxhdpi"/>
</platform>
<icon src="icon.png" />
<gap:splash src="splash.png" />

正如 phonegap 文档所述:您的启动画面应保存为 png 文件。 它们是什么,我添加了平台标签“gap:platform”

并且默认的启动画面必须命名为 splash.png 并且必须位于应用程序文件夹的根目录中。

这是我的项目树

root
- bower_components
- hooks
- node_modules
- platforms
- plugins

- resources
-- android
--- icon
--- splash
  drawable-land-hdpi-screen.png
  drawable-land-ldpi-screen.png
  drawable-land-mdpi-screen.png
  etc...
-- ios
--- icon
--- splash
  Default-568h@2x~iphone.png
  Default-667h.png
  Default-736h.png
  etc...
-- icon.png
-- splash.png
- scss
- www

bower.json
config.xml
gulpfile.js
icon.png
ionic.project
package.json
splash.png

http://i59.tinypic.com/9bhbw5.jpg

我希望有人能给我一个解决方案 提前谢谢你

编辑:

我已经从启动屏幕工作的模拟器和 phonegap 构建的 APK 文件反编译了 APK 文件。看起来 phonegap 不会复制启动画面文件夹,也没有使用正确的 config.xml 文件。

phonegap 构建中的 config.xml

    <?xml version="1.0" encoding="utf-8"?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
    <name> Hello Cordova
</name>
    <description> A sample Apache Cordova application that responds to the deviceready
        event. </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io"> Apache Cordova Team </author>
    <access origin="http://*/*" />
    <access origin="https://*/*" />
    <access launch-external="yes" origin="tel:*" />
    <access launch-external="yes" origin="geo:*" />
    <access launch-external="yes" origin="mailto:*" />
    <access launch-external="yes" origin="sms:*" />
    <access launch-external="yes" origin="market:*" />
    <preference name="loglevel" value="DEBUG" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="ShowSplashScreenSpinner" value="true" />
    <preference name="SplashScreenDelay" value="5000" />
    <content src="index.html" />
    <feature name="StatusBar">
        <param name="android-package" onload="true" value="org.apache.cordova.statusbar.StatusBar" />
    </feature>
    <feature name="AppVersion">
        <param name="android-package" value="uk.co.whiteoctober.cordova.AppVersion" />
    </feature>
    <feature name="Keyboard">
        <param name="android-package" value="com.ionic.keyboard.IonicKeyboard" />
        <param name="onload" value="true" />
    </feature>
    <feature name="InAppBrowser">
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
    </feature>
    <feature name="NetworkStatus">
        <param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
    </feature>
    <feature name="Device">
        <param name="android-package" value="org.apache.cordova.device.Device" />
    </feature>
    <feature name="SocialSharing">
        <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
    </feature>
    <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
    </feature>
    <feature name="GeolocationAvailabilityChecker">
        <param name="android-package" value="org.apache.cordova.geolocation.GeolocationAvailabilityChecker" />
    </feature>
</widget>

看起来 phonegap 构建配置不正确

【问题讨论】:

  • 默认情况下,在我的项目中,ios 会显示启动画面。但是,android 不是因为我使用这行: 在 config.xml 的 android res - > xml -> config.xml 文件
  • 您是否尝试在其他 config.xml 文件中进行此更改?我遇到了类似的问题,当我在 android 和 ios 文件夹中更改 config.xml 文件时,它起作用了。
  • 感谢您的cmets,我已经删除了android平台并重新添加了android并构建它本地config.xml具有相同的结构; ' 和默认启动画面标签''

标签: android ios cordova ionic


【解决方案1】:

如果有人仍然遇到此问题,请在运行 ionic resources 命令后确保将以下内容添加到 config.xml:

  <preference name="ShowSplashScreen" value="true" />
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <preference name="AutoHideSplashScreen" value="true" />
  <preference name="SplashShowOnlyFirstTime" value="false" />
  <preference name="FadeSplashScreen" value="false"/>
  <feature name="SplashScreen">
    <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
  </feature>

然后运行:

ionic build android
ionic run android

完成。

【讨论】:

  • "FadeSplashScreen" = false 让我开心!谢谢,戴夫!
【解决方案2】:

对于未来,有一种更好的方法可以使用 ionic 添加启动画面: 您需要做的就是编辑位于resources 文件夹中的icon 和splash 2 个图像。

在那个类型之后 $ ionic resources 它将为您生成所有内容,包括配置文件 Documentation can be found here.

这适用于安卓和IOS

注意:不要忘记添加 cordova 闪屏插件

ionic plugin add cordova-plugin-splashscreen

【讨论】:

    【解决方案3】:

    对于有同样问题的人,

    我必须在 www 文件夹中添加一个文件夹,例如文件夹 res。在里面我放了我所有的闪屏并像这样配置了我的 config.xml:

    <content src="index.html"/>
      <access origin="*"/>
      <preference name="webviewbounce" value="false"/>
      <preference name="UIWebViewBounce" value="false"/>
      <preference name="DisallowOverscroll" value="true"/>
      <preference name="BackupWebStorage" value="none"/>
      <preference name="android-minSdkVersion" value="16"/>
    
      <gap:plugin name="org.apache.cordova.splashscreen" />
    
      <preference name="SplashScreen" value="screen"/>
    
      <preference name="SplashScreenDelay" value="4000" />
    
      <gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/drawable-port-ldpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/drawable-port-mdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/drawable-port-hdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/drawable-port-xhdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="port-xxhdpi" src="res/drawable-port-xxhdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="port-xxxhdpi" src="res/drawable-port-xxxhdpi/screen.png" />
    
      <gap:splash gap:platform="android" gap:qualifier="land-ldpi" src="res/drawable-land-ldpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="land-mdpi" src="res/drawable-land-mdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="land-hdpi" src="res/drawable-land-hdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="land-xhdpi" src="res/drawable-land-xhdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="land-xxhdpi" src="res/drawable-land-xxhdpi/screen.png" />
      <gap:splash gap:platform="android" gap:qualifier="land-xxxhdpi" src="res/drawable-land-xxxhdpi/screen.png" />
    
      <!-- iPhone 4 and iPod touch -->
      <gap:splash src="res/ios/iphone4/Default.png" gap:platform="ios" width="320" height="480" />
      <gap:splash src="res/ios/iphone4/Default@2x.png" gap:platform="ios" width="640" height="960" />
    
      <!-- iPhone 5 / iPod Touch (5th Generation) -->
      <gap:splash src="res/ios/iphone5/Default-568h@2x.png" gap:platform="ios" width="640" height="1136" />
    
      <!-- iPhone 6 -->
      <gap:splash src="res/ios/iphone6/Default-667h@2x.png" gap:platform="ios" width="750" height="1334" />
      <gap:splash src="res/ios/iphone6/Default-Portrait-736h@3x.png" gap:platform="ios" width="1242" height="2208" />
      <gap:splash src="res/ios/iphone6/Default-Landscape-736h@3x.png" gap:platform="ios" width="2208" height="1242" />
    
      <!-- iPad -->
      <gap:splash src="res/ios/Default-Portrait.png" gap:platform="ios" width="768" height="1024" />
      <gap:splash src="res/ios/Default-Landscape.png" gap:platform="ios" width="1024" height="768" />
    
      <!-- Retina iPad -->
      <gap:splash src="res/ios/Default-Portrait@2x.png" gap:platform="ios" width="1536" height="2048" />
      <gap:splash src="res/ios/Default-Landscape@2x.png" gap:platform="ios" width="2048" height="1536" />
    
      <gap:splash src="splash.png" />
    
      <gap:plugin name="org.apache.cordova.device"/>
      <gap:plugin name="org.apache.cordova.network-information"/>
      <gap:plugin name="org.apache.cordova.inappbrowser"/>
      <gap:plugin name="uk.co.whiteoctober.cordova.appversion" version="0.1.4"/>
      <gap:plugin name="org.apache.cordova.statusbar" version="0.1.4" source="pgb"/>
      <gap:plugin name="com.ionic.keyboard" version="1.0.3" source="pgb"/>
      <gap:plugin name="nl.x-services.plugins.socialsharing" version="4.3.8" source="pgb"/>
      <gap:plugin name="fi.avaus.cordova.geolocation"/>
      <platform name="ios">
        <icon src="resources/ios/icon/icon.png" gap:platform="ios" width="57" height="57"/>
        <icon src="resources/ios/icon/icon@2x.png" gap:platform="ios" width="114" height="114"/>
        <icon src="resources/ios/icon/icon-40.png" gap:platform="ios" width="40" height="40"/>
        <icon src="resources/ios/icon/icon-40@2x.png" gap:platform="ios" width="80" height="80"/>
        <icon src="resources/ios/icon/icon-50.png" gap:platform="ios" width="50" height="50"/>
        <icon src="resources/ios/icon/icon-50@2x.png" gap:platform="ios" width="100" height="100"/>
        <icon src="resources/ios/icon/icon-60.png" gap:platform="ios" width="60" height="60"/>
        <icon src="resources/ios/icon/icon-60@2x.png" gap:platform="ios" width="120" height="120"/>
        <icon src="resources/ios/icon/icon-60@3x.png" gap:platform="ios" width="180" height="180"/>
        <icon src="resources/ios/icon/icon-72.png" gap:platform="ios" width="72" height="72"/>
        <icon src="resources/ios/icon/icon-72@2x.png" gap:platform="ios" width="144" height="144"/>
        <icon src="resources/ios/icon/icon-76.png" gap:platform="ios" width="76" height="76"/>
        <icon src="resources/ios/icon/icon-76@2x.png" gap:platform="ios" width="152" height="152"/>
        <icon src="resources/ios/icon/icon-small.png" gap:platform="ios" width="29" height="29"/>
        <icon src="resources/ios/icon/icon-small@2x.png" gap:platform="ios" width="58" height="58"/>
        <icon src="resources/ios/icon/icon-small@3x.png" gap:platform="ios" width="87" height="87"/>
      </platform>
      <platform name="android">
        <icon src="resources/android/icon/drawable-ldpi-icon.png" gap:platform="android" density="ldpi"/>
        <icon src="resources/android/icon/drawable-mdpi-icon.png" gap:platform="android" density="mdpi"/>
        <icon src="resources/android/icon/drawable-hdpi-icon.png" gap:platform="android" density="hdpi"/>
        <icon src="resources/android/icon/drawable-xhdpi-icon.png" gap:platform="android" density="xhdpi"/>
        <icon src="resources/android/icon/drawable-xxhdpi-icon.png" gap:platform="android" density="xxhdpi"/>
        <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" gap:platform="android" density="xxxhdpi"/>
      </platform>
    
      <icon src="icon.png" />
    

    本教程中的大多数输入(非常有帮助) https://www.youtube.com/watch?v=9KVvaZPhGWo

    【讨论】:

      【解决方案4】:

      确保安装插件:

      cordova插件添加cordova-plugin-splashscreen

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-07
        • 2014-10-12
        • 2014-05-05
        • 2016-04-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多