【问题标题】:Cordova android app not showing icon on home screenCordova android 应用程序未在主屏幕上显示图标
【发布时间】:2017-10-31 13:47:31
【问题描述】:

我们有一个由 cordova 提供支持的网络应用程序来生成移动应用程序。一切都可以在 iOS 上运行。

我们正在尝试添加 android 平台,除了应用程序图标外,其他一切都运行良好。

config.xml 主要遵循on the docs

<widget
    id="xxx"
    version="xxx"
    ios-CFBundleVersion="xxx"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:cdv="http://cordova.apache.org/ns/1.0"
>
    <name>xxx</name>
    <description></description>
    <author email="xxx" href="xxx">xxx</author>
    <content src="index.html" />

    <engine name="ios" spec="~4.5.1" />
    <engine name="android" spec="~6.3.0" />

    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="BackupWebStorage" value="none" />
        <preference name="deployment-target" value="8.0" />
        <preference name="KeyboardDisplayRequiresUserAction" value="false" />
        <preference name="UIWebViewDecelerationSpeed" value="normal" />

        <icon src="resources/icons/Icon-Small.png" width="29" height="29" />
        <icon src="resources/icons/Icon-Small@2x.png" width="58" height="58" />
        <icon src="resources/icons/Icon-Small@3x.png" width="87" height="87" />
        <icon src="resources/icons/Icon-40.png" width="40" height="40" />
        <icon src="resources/icons/Icon-50.png" width="50" height="50" />
        <icon src="resources/icons/Icon-50@2x.png" width="100" height="100" />
        <icon src="resources/icons/Icon.png" width="57" height="57" />
        <icon src="resources/icons/Icon@2x.png" width="114" height="114" />
        <icon src="resources/icons/Icon-40@2x.png" width="80" height="80" />
        <icon src="resources/icons/Icon-40@3x.png" width="120" height="120" />
        <icon src="resources/icons/Icon-60.png" width="60" height="60" />
        <icon src="resources/icons/Icon-60@2x.png" width="120" height="120" />
        <icon src="resources/icons/Icon-60@3x.png" width="180" height="180" />
        <icon src="resources/icons/Icon-72.png" width="72" height="72" />
        <icon src="resources/icons/Icon-72@2x.png" width="144" height="144" />
        <icon src="resources/icons/Icon-76.png" width="76" height="76" />
        <icon src="resources/icons/Icon-76@2x.png" width="152" height="152" />
        <icon src="resources/icons/Icon-83.5.png" width="83.5" height="83.5" />
        <icon src="resources/icons/Icon-83.5@2x.png" width="167" height="167" />
        <icon src="resources/icons/iTunesArtwork@2x.png" width="1024" height="1024" />

        <preference name="ShowSplashScreenSpinner" value="false"/>

        <splash src="resources/splash/Default@2x~universal~anyany.png" width="2732" height="2732"/>
    </platform>

    <platform name="android">
        <allow-intent href="market:*" />

        <icon src="resources/icons/ldpi.png" density="ldpi" />
        <icon src="resources/icons/mdpi.png" density="mdpi" />
        <icon src="resources/icons/hdpi.png" density="hdpi" />
        <icon src="resources/icons/xhdpi.png" density="xhdpi" />
        <icon src="resources/icons/xxhdpi.png" density="xxhdpi" />
        <icon src="resources/icons/xxxhdpi.png" density="xxxhdpi" />

        <splash src="resources/splash/splash-land-hdpi.png" density="land-hdpi"/>
        <splash src="resources/splash/splash-land-ldpi.png" density="land-ldpi"/>
        <splash src="resources/splash/splash-land-mdpi.png" density="land-mdpi"/>
        <splash src="resources/splash/splash-land-xhdpi.png" density="land-xhdpi"/>
        <splash src="resources/splash/splash-port-hdpi.png" density="port-hdpi"/>
        <splash src="resources/splash/splash-port-ldpi.png" density="port-ldpi"/>
        <splash src="resources/splash/splash-port-mdpi.png" density="port-mdpi"/>
        <splash src="resources/splash/splash-port-xhdpi.png" density="port-xhdpi"/>

        <preference name="AndroidPersistentFileLocation" value="Compatibility" />
    </platform>

    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-navigation href="https://*/*" />
    <allow-intent href="mailto:*" />
    <allow-navigation href="mailto:*" />

    <universal-links>
        <ios-team-id value="xxx" />
        <host name="$host" scheme="$scheme" event="universal-link-clicked"/>
    </universal-links>

    <plugin name="cordova-plugin-file-transfer" spec="~1.6.2" />
    <plugin name="cordova-plugin-file" spec="~4.3.3" />
    <plugin name="cordova-plugin-network-information" spec="~1.3.2" />
    <plugin name="cordova-plugin-statusbar" spec="~2.2.2" />
    <plugin name="cordova-plugin-background-fetch" spec="https://github.com/christocracy/cordova-plugin-background-fetch.git" />
    <plugin name="cordova-plugin-inappbrowser" spec="~1.7.0" />
    <plugin name="cordova-plugin-disable-bitcode" spec="~1.3.2" />
    <plugin name="com.batch.cordova" spec="https://github.com/floo51/cordova-plugin.git" />
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.2" />
    <plugin name="cordova-plugin-ios-non-exempt-encryption" spec="~1.0.0" />
    <plugin name="cordova-universal-links-plugin" spec="~1.2.1" />
</widget>

有不同类型的图标:

  • APK 文件图标(有效)
  • 安装屏幕(工作)
  • 应用程序菜单(不起作用)
  • 主屏幕(不起作用)

  • 正在运行的应用程序(不起作用)

最奇怪的是它可以在模拟器(nexus 5)上运行,但不能在 OnePlus One 或 Moto G4 上运行。

我们使用的是科尔多瓦 6.5。所有图标都根据what's on the docs 调整大小。我们错过了什么吗?

【问题讨论】:

  • 该图标确实有效,但它是默认图标,表示您的resources 文件夹或platforms 文件夹有问题。您应该检查resources 文件夹是否包含您的图标的所有大小,并解决您通常在删除platforms 文件夹后通过运行cordova platform add android@latest 读取android 平台的问题。您还应该考虑从 cordova 6.5 升级到最新版本。

标签: android cordova icons


【解决方案1】:

我推荐两件事:

1) 使用qualifier 而不是density。示例:

<icon src="resources/icons/ldpi.png" qualifier="ldpi" />

2) 在项目的根文件夹中添加默认图标和启动画面作为后备:

<icon src="icon.png" />
<splash src="splash.png" />

【讨论】:

  • 哇! qualifier 确实解决了这个问题......需要一些文档更新。谢谢!
猜你喜欢
  • 1970-01-01
  • 2023-01-10
  • 2015-10-17
  • 1970-01-01
  • 2016-10-02
  • 1970-01-01
  • 1970-01-01
  • 2011-12-14
  • 2019-02-10
相关资源
最近更新 更多