Chrome扩展加载报错:'icons'值无效问题求助
Chrome扩展Manifest加载错误:"Invalid value for 'icons'"排查方案
核心问题:路径格式错误
你的manifest中图标路径开头使用了斜杠(/),这会被Chrome解析为系统根路径,导致无法定位到扩展目录下的图标文件。Chrome扩展引用本地资源需使用相对路径(以manifest.json所在目录为起点),不能加开头的斜杠。
修正步骤:
- 调整
icons字段的路径:删除每个src值开头的/,比如将"/icons/Google-Chrome-Google-Chrome.16.png"改为"icons/Google-Chrome-Google-Chrome.16.png" - 修正
action.default_icon的路径:同样去掉开头的/,改为"icons/Google-Chrome-Google-Chrome.16.png"
修正后的完整manifest代码:
{ "manifest_version": 3, "name": "Assessment tool", "version": "1.0", "description": "Scrapes information from website and performs a set of calculations", "icons": [ { "src": "icons/Google-Chrome-Google-Chrome.16.png", "sizes": "16x16", "type": "image/png" }, { "src": "icons/Google-Chrome-Google-Chrome.48.png", "sizes": "48x48", "type": "image/png" }, { "src": "icons/Google-Chrome-Google-Chrome.128.png", "sizes": "128x128", "type": "image/png" } ], "action": { "default_icon": "icons/Google-Chrome-Google-Chrome.16.png", "default_title": "Assessment tool", "default_popup": "popup.html" }, "host_permissions": [ "https://www.assessment.co.uk/*" ], "web_accessible_resources": [ { "resources": [ "/popup.css", "/popup.html", "/script.js" ], "matches": [ "https://*/*", "http://*/*" ] } ] }
额外验证项:
- 确认
icons文件夹与manifest.json处于同一目录,图标文件名和代码中完全一致(Linux/macOS环境需注意大小写区分) - 检查图标文件是否为有效PNG格式,没有损坏
内容的提问来源于stack exchange,提问作者gator123
相关产品推荐
相关产品推荐

