简体   繁体   中英

I can not change android cordova icon

I am trying to change my app icon in the config.xml file. I have read w3.org documents and, i supose, with this code must be enought.

<platform name="android">
    <icon src="res/icon/logo.png" /> 
</platform>

However i have this fail and it does not works:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'icon'. One of '{" http://www.w3.org/ns/widgets ":allow-intent, "http:// www.w3.org/ns/widgets":allow-navigation, " http://www.w3.org/ns/widgets ":plugin, " http://www.w3.org/ns/widgets ":preference, "http:// www.w3.org/ns/widgets":hook}' is expected.

So i try it like this way:

<platform name="android">
        <allow-intent href="market:*" />
        <allow-intent href="http://www.w3.org/ns/widgets"/>
        <allow-navigation href="http://www.w3.org/ns/widgets"/>
        <icon src="res/icon.png" />
</platform>

And the error keep being. This is my complete config.xml code:

<?xml version='1.0' encoding='utf-8'?>
<widget id="tta.kirolapp.v1" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Kirol App v1</name>
    <description>
        A sample Apache Cordova application that responds to the
        deviceready
        event.
    </description>
    <author email="thym-dev@eclipse.org" href="http://www.eclipse.org/thym">
        Eclipse.org - Thym
    </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:*" />
        <allow-intent href="http://www.w3.org/ns/widgets"/>
        <allow-navigation href="http://www.w3.org/ns/widgets"/>
        <icon src="res/icon.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <engine name="android" spec="6.1.0" />
    <preference name="Orientation" value="portrait" />


</widget>

Config xml file: 在此处输入图片说明

It should be like

    <platform name="android">
    <!--
        ldpi    : 36x36 px
        mdpi    : 48x48 px
        hdpi    : 72x72 px
        xhdpi   : 96x96 px
        xxhdpi  : 144x144 px
        xxxhdpi : 192x192 px
    -->
    <icon src="res/android/ldpi.png" density="ldpi" />
    <icon src="res/android/mdpi.png" density="mdpi" />
    <icon src="res/android/hdpi.png" density="hdpi" />
    <icon src="res/android/xhdpi.png" density="xhdpi" />
    <icon src="res/android/xxhdpi.png" density="xxhdpi" />
    <icon src="res/android/xxxhdpi.png" density="xxxhdpi" />
</platform>

have a look at Cordova Docs for more platforms and detailed information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM