1

I'm trying to change the icon of the aplication I'm building with Cordova through Eclipse.

I've tried 2 different methods, which both failed. I first tried to add the following kind of lines to my projroot/www/config.xml:

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

Which results in:

 [aapt] C:\Program Files (x86)\eclipse\configuration\org.eclipse.osgi\920\data\proj_gen\csam.test\android\bin\AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon').

BUILD FAILED
C:\Users\Pieter\AppData\Local\Android\android-sdk\tools\ant\build.xml:649: The following error occurred while executing this line:
C:\Users\Pieter\AppData\Local\Android\android-sdk\tools\ant\build.xml:694: null returned: 1

I also found a second approach through hooks. But this just didn't change anything. Below is a screenshot of my filestructure and below you can find the hook script. Maybe the hook script doesn't get executed when building through eclipse?

#!/usr/bin/env node

//
// This hook copies various resource files 
// from our version control system directories 
// into the appropriate platform specific location
//


// configure all the files to copy.  
// Key of object is the source file, 
// value is the destination location.  
// It's fine to put all platforms' icons 
// and splash screen files here, even if 
// we don't build for all platforms 
// on each developer's box.

var filestocopy = [{
    "config/android/res/drawable/icon.png": 
    "platforms/android/res/drawable/icon.png"
}, {
    "config/android/res/drawable-hdpi/icon.png": 
    "platforms/android/res/drawable-hdpi/icon.png"
}, {
    "config/android/res/drawable-mdpi/icon.png": 
    "platforms/android/res/drawable-mdpi/icon.png"
}, {
    "config/android/res/drawable-xhdpi/icon.png": 
    "platforms/android/res/drawable-xhdpi/icon.png"
}, ];

var fs = require('fs');
var path = require('path');

// no need to configure below
var rootdir = process.argv[2];

filestocopy.forEach(function(obj) {
    Object.keys(obj).forEach(function(key) {
        var val = obj[key];
        var srcfile = path.join(rootdir, key);
        var destfile = path.join(rootdir, val);
        //console.log("copying "+srcfile+" to "+destfile);
        var destdir = path.dirname(destfile);
        if (fs.existsSync(srcfile) &amp;&amp; fs.existsSync(destdir)) {
            fs.createReadStream(srcfile).pipe(
               fs.createWriteStream(destfile));
        }
    });
});

enter image description here

Spyral
  • 760
  • 1
  • 12
  • 33

1 Answers1

0

You have to configure your AndroidManifest.xml file to make it point to your icon :

<application android:hardwareAccelerated=”true” android:icon=”@drawable/myIcon” android:label=”@string/app_name”>

Command line compilation :

Open cmd

cd yourproject

cordova platforms add android

You will get a folder and go to and make the modification with the line I told you first.

/android/platforms/AndroidManifest.xml

Finally

cordova run android
AshBringer
  • 2,614
  • 2
  • 20
  • 42
  • Where can I find that file? I can't find it in my project folder. I did find "a location" before where stuff like that was stored but that was just overwritten whenever I built with eclipse. I just changed the logos there to my own, which just defaulted back to the cordova icons after I built. – Spyral Jul 03 '15 at 09:00
  • I can't tell, the structure of your project is different from mine. I have it under platforms/android/AndroidManifest.xml but if you don't find it, just make a search on your C:\ folder. The overwritten problem is a known issue. http://stackoverflow.com/questions/17820492/how-to-add-app-icon-within-phonegap-projects?lq=1 – AshBringer Jul 03 '15 at 09:07
  • Well I found it but like I said the location where the manifest, and resources, are stored gets overwritten every time I build. http://i.imgur.com/CUc0diu.png – Spyral Jul 03 '15 at 09:16
  • Yeah I see. This is due to the compilation Eclipse is doing, it's overwrting everything. I came accross this issue, with doing all the compilation with the command line from scratch, but when you will re-compil the project you'll get the default icon back – AshBringer Jul 03 '15 at 09:22
  • Yeah that's why I tried to use the hook method I described in my initial post, I tried to use an after_prepare hook, but it doesn't seem to be working, not even sure if it's getting executed.. Also, how dumb is it that you can't configure basic stuff like your application icon in your project file by default.. If you encountered the problem before, how did you eventually fix it? – Spyral Jul 03 '15 at 09:26
  • I've edited the answer, hope it helps , it's been a long time , I just let it go as it was annoying issue – AshBringer Jul 03 '15 at 09:28
  • 1
    If this doesn't fix it I think I'll just resort to http://kefir500.github.io/apk-icon-editor/download/ :p Manual labor for the win.. Thanks for the help! – Spyral Jul 03 '15 at 09:42
  • I just came back from a lunchbreak, haven't tested your solution yet, but yes the tool worked flawlessly! I'm considering checking out if it works through command line as well and just writing a script that I can execute post-build. – Spyral Jul 03 '15 at 10:27