繁体   English   中英

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

[英]Change icon of application in Cordova eclipse project

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

我尝试了2种不同的方法,但都失败了。 我首先尝试将以下几行添加到我的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

我还通过钩子找到了第二种方法。 但这并没有改变任何东西。 下面是我的文件结构的屏幕截图,下面是钩子脚本。 通过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));
        }
    });
});

在此处输入图片说明

您必须配置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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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