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?

Categories

HOME
testing
blogger
netbeans
magnific-popup
image-processing
google-play
json.net
include
objectgears
sqlite-net-extensions
jsrender
youtube-api-v3
rdf
packages
win32gui
fsm
webpack-2
autotools
cross-validation
awesome-wm
python-unittest
windows-10-universal
node-pdfkit
wheelnav.js
row
alignment
carthage
jsdoc
jtextfield
mps
extjs5
lcd
qhull
info.plist
fifo
dbclient
madlib
xquery-3.0
exuberant-ctags
code-contracts
commit
subset-sum
amazon-kinesis-kpl
mapdb
ios5
file-format
space-complexity
sharefile
vapor
ssjs
uft-api
http-live-streaming
arena-simulation
heightmap
modelmapper
qcombobox
qwt
revapi
theming
powercli
csound
typed-lambda-calculus
nsarray
google-feed-api
pcf
thrust
nsfilemanager
ctest
storekit
gridview-sorting
multiple-regression
fadeout
kendonumerictextbox
spim
sdhc
feedback
ionic
createprocessasuser
system32
sonarqube5.1.2
npapi
block-device
c3
camanjs
starcluster
funcunit
p4java
poller
srs
html5-notifications
geos
ccss
yui-compressor
seed
interface-orientation
ocunit
mhtml
browser-detection
libstdc++
runas
viewswitcher
hosts-file
bigcouch
subscript
qt-jambi
genshi
cinema-4d
icanhaz.js
bespin
meego
javap
temporal-database
spec#
data-acquisition
commodore
caching-application-block

Resources

Encrypt Message