科尔多瓦图标和splashscreen无法正常工作

时间:2016-12-11 14:34:30

标签: android cordova cordova-plugins

我在这里面临困境。我的cordova应用程序工作正常,但图标和splashscreen不,他们反映默认的cordova图标和splashscreen。 我的config.xml如下所示,图标和图像存在于我的目录路径中,但它们没有被反映出来。 cordova s​​plashcreen插件也正确安装。我可能做错了什么?

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.something.portal" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Someapp</name>
    <description>
        Someapp
    </description>
    <author email="cliffjimmy27@gmail.com" href="https://gmail.com">
        Obonyo Jimmycliff
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <access origin="cdvfile://*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <icon src="res/icon.png" />
    <platform name="android">
        <allow-intent href="market:*" />
        <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
        <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
        <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
        <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>

        <splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi"/>
        <splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi"/>
        <splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi"/>
        <splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi"/>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.0" />
    <plugin name="cordova-plugin-camera" spec="~2.3.0" />
    <plugin name="cordova-plugin-file-transfer" spec="~1.6.0" />
    <plugin name="cordova-plugin-file" spec="~4.3.0" />
    <plugin name="cordova-plugin-geolocation" spec="~2.4.0" />
</widget>

2 个答案:

答案 0 :(得分:1)

当前Dev-Versions:

  • cordova-version:6.0.0
  • ionic-version:1.7.14

请注意,我只能为自己说话:

我刚刚创建了一个testapp,虽然图标工作,但我也遇到了与splash-images相同的问题。事实证明,首选项 SplashScreenDelay 设置得太低了。当您使用ionic创建cordova项目时, SplashScreenDelay 被指定为2秒(2000),在我的情况下太低了。我一看到第一页,就会有2秒钟结束。

根据this,默认值是5秒,但是当我删除 SplashScreenDelay 时,我看到没有启动图像,但只要我为 SplashScreenDelay分配了5秒settings关闭应用程序之后没有任何启动图像,它再次显示。让我们说这里很奇怪。

因此,我建议您使用cordova-plugin-splashscreen插件,以确保无论您是否为 SplashScreenDelay 分配了较低的值,都会始终显示您的启动图像。< / p>

config.xml中:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testapp128533" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>testapp</name>
  <description>
        An Ionic Framework and Cordova project.
    </description>
  <author email="you@example.com" href="http://example.com/">
      Your Name Here
    </author>
  <content src="index.html"/>
  <access origin="*"/>
  <preference name="SplashScreenDelay" value="5000"/>
  <icon src="icon.png" />
  <platform name="android">
    <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi/screen.png" />
    <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi/screen.png" />
    <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi/screen.png" />
    <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi/screen.png" />
    <splash density="hdpi" src="resources/android/splash/drawable-hdpi/screen.png" />
    <splash density="ldpi" src="resources/android/splash/drawable-ldpi/screen.png" />
    <splash density="mdpi" src="resources/android/splash/drawable-mdpi/screen.png" />
    <splash density="xhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="land-xxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="land-xxxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="port-xxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="port-xxxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="xxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
    <splash density="xxxhdpi" src="resources/android/splash/drawable-xhdpi/screen.png" />
  </platform>
</widget>

项目目录:

enter image description here

答案 1 :(得分:0)

Cordova不支持所有ios设备。要使用一个文件生成所有可能的图标和启动画面,我只建议使用cordova-icon cordova-splash

说明很容易理解,我在5分钟内完成了所有工作。