You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cordova Android应用图标配置报错:资源路径不存在

Cordova Android 图标配置正确路径指南

核心问题:资源路径的根是项目根目录

你配置的res/icons/mipmap-xxx/ic_launcher.png是相对于项目根目录的路径,而非www或platforms子目录。正确的文件夹结构应该是:

你的Cordova项目根目录/
├─ res/
│  └─ icons/
│     ├─ mipmap-hdpi/
│     │  └─ ic_launcher.png
│     ├─ mipmap-mdpi/
│     │  └─ ic_launcher.png
│     ├─ mipmap-xhdpi/
│     │  └─ ic_launcher.png
│     └─ mipmap-xxhdpi/
│        └─ ic_launcher.png
├─ www/
├─ platforms/
└─ config.xml

验证配置的正确写法

在config.xml的android平台节点下,配置需与路径对应,示例如下:

<platform name="android">
    <icon density="ldpi" src="res/icons/mipmap-ldpi/ic_launcher.png" />
    <icon density="mdpi" src="res/icons/mipmap-mdpi/ic_launcher.png" />
    <icon density="hdpi" src="res/icons/mipmap-hdpi/ic_launcher.png" />
    <icon density="xhdpi" src="res/icons/mipmap-xhdpi/ic_launcher.png" />
    <icon density="xxhdpi" src="res/icons/mipmap-xxhdpi/ic_launcher.png" />
    <icon density="xxxhdpi" src="res/icons/mipmap-xxxhdpi/ic_launcher.png" />
</platform>

额外注意事项

  • 不要手动修改platforms/android/下的资源,Cordova会自动从项目根目录的res文件夹同步资源到平台目录,手动修改会被覆盖。
  • 若之前错误修改过platforms目录,可执行cordova clean android清理后,再运行cordova build android确保资源同步正确。
  • 确认所有图标文件的文件名、路径拼写完全匹配配置内容,Linux/macOS环境下需注意大小写敏感问题。

内容的提问来源于stack exchange,提问作者DaraJ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 20:36:27