google-chrome-extension
Chrome Extension error: “Unchecked runtime.lastError while running browserAction.setIcon: Icon invalid."
I was trying to change Chrome extension icon dynamically by following this documentation. Unfortunately, it is not working with the following code: chrome.browserAction.setIcon({path: 'my_icon.png'}); In console, it is failing with following error: Unchecked runtime.lastError while running browserAction.setIcon: Icon invalid.
After reading elsewhere on the web, I found that we need to specify images with size either (or both) of 19x19 px or 38x38 px. So I resized my icon image, and made 2 copies of it as follows: my_icon-19.png my_icon-38.png Now when I tried the following code, it worked as expected: chrome.browserAction.setIcon({ path: { "19": "/images/my_icon-19.png", "38": "/images/my_icon-38.png" } }); You do not need both of the versions to make it work, so following would work as well: chrome.browserAction.setIcon({ path: "/images/my_icon-38.png" });
Related Links
Is there a limit on number of requests to Chrome history API from an extension?
when URL does not exists it shows the alert twice? Chrome Extension Developing
how to popup my google chrome extension
Upload stuck on Chrome Extension
how do i set the browseraction popup width and height?
Using a remote script in a Google Chrome extension
Chrome extension and history.onVisited event
jQuery in Google Chrome Content Script?
Can a Chrome extension monitor XHR events (or other events) from the page it's running against?
Getting current window on a popup (google chrome extension)
Accessing browser events in chrome extension - DOM events in chrome extension
Chrome extension: Attaching current tab to popup and then going through its DOM
Problem about Chrome Extension
How should a chrome extension background page communicate with multiple content scripts?
Detecting Google Chrome Browser Extensions
Location of CRX in chrome after installation?