I have a freshly created Cordova project with the following config.xml
setup (used the instructions from http://docs.phonegap.com/en/edge/config_ref_images.md.html). I also added 2 platforms (iOS and Android).
When I run either cordova run ios
or cordova run android
, the project still has the default Cordova icons. My understanding from the documentation is that Corodva is supposed to create the icons automatically based in the icon.png
I supplied in the config.xml
.
config.xml
:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.testapp" version="1.1.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>SingleApp</name>
<preference name="DisallowOverscroll" value="true" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="Orientation" value="portrait" />
<preference name="Fullscreen" value="false" />
<preference name="target-device" value="handset" />
<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>
<content src="index.html" />
<access origin="*" />
<icon src="icon.png" />
</widget>
Don't you need to specify the folder that has the icon on it? Cordova replaces the icon with the default one when it is not found.
Have you tried to replace with something like:
A little explication for people who say
<icon src="res/icon.png" />
Not work !You must put icon.png in both this folders
and
Steps:
Copy your icon.png to
project_name/res/
Openconfig.xml
and put<icon src="res/icon.png" />
After that run
Now copy your icon.png to ...
hello/platforms/android/res/
then
and finally
After that you can see on device your app with your icon
I wrote a script that auto generates icons for cordova using ImageMagick:
https://github.com/AlexDisler/cordova-icon
To use it, create an "icon.png" file and place it in the root folder of your project, then run:
and it will generate all the required icons for the platforms your project has.
You can also configure it as a hook in your cordova project so the icons will be generated every time you build the project based on the icon.png you've added. (instructions in the readme).
If you are using cordova 3.5.0 they have updated the docs. In older versions i've always had to replace the icons manually in the project but the latest version of cordova is working fine.
http://cordova.apache.org/docs/en/3.5.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens
As you can see here https://github.com/phonegap/phonegap-cli/issues/58 it's been a common problem. So if you are using an older version of cordova i recommend to update it with the command
npm update -g cordova
And after that you should update your config.xml to something like this:
As you can see the URIs are relative to the cordova project's path, not to the www folder.
The
config.xml
settings for icons only works with the PhoneGap Build service. After adding both of your platforms you need to manually (or you can create a hook, but I haven't done that myself) place your icons in the correct paths.For iOS:
For Android:
Android has many
res/drawable-*
folders, use as applies to your app but at minimum add tores/drawable
Then run
cordova prepare
orbuild
orrun
If you are willing to install extra software for icon generation you can use Ionic which has such function.
Do the following:
npm install ionic -g
${project_location}/resources
ionic resources
If you want to generate icons only there is a handy key for that:
More details here