在Cordova eclipse项目中更改应用程序的图标

时间:2015-07-03 08:42:15

标签: android eclipse cordova

我正在尝试通过Eclipse更改我正在使用Cordova构建的应用程序的图标。

我尝试了两种不同的方法,都失败了。 我首先尝试将以下类型的行添加到我的projroot / www / config.xml中:

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

结果是:

 [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

status 但这并没有改变任何事情。下面是我的文件结构的截图,下面你可以找到钩子脚本。也许在通过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

1 个答案:

答案 0 :(得分:0)

您必须配置AndroidManifest.xml文件,使其指向您的图标:

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

命令行编译:

Open cmd

cd yourproject

cordova platforms add android

您将获得一个文件夹,然后使用我先告诉您的行进行修改。

/android/platforms/AndroidManifest.xml

最后

cordova run android