0

In package.json, I have tried with and without a resource://, a name, a GUID, both name and GUID, neither name nor GUID, With {}s, without {}s, with @, relative and absolute, assuming ./ (relative), / (root), /data.

I simply can not get the addon manager to display an icon from the addon, even after install, at all. I can't even get jpm to create an em:iconURL in the install.rdf. It's simply not even there. There are no errors on the command line using jpm. There are no errors in the console, at least none that relate to anything I am doing, at least not that clearly explain that they relate to anything I am doing. For demonstration purposes of what I have tried. Not an actual working example. For each of the different formats I attempted, I put the same format URI for all size icons (16, 32, 48, 64).

package.json (demo snippet):

...
"id": "{GUID}",
"name": "my_addon",
"icons": {
    "48": "resource://@{GUID}/data/myaddon-48.png",
    "48": "resource://GUID/data/myaddon-48.png",
    "48": "resource://@my_addon/data/myaddon-48.png",
    "48": "resource://my_addon/data/myaddon-48.png",
    "64": "myaddon-64.png",
    "64": "/myaddon-64.png",
    "64": "./myaddon-64.png",
    "64": "data/myaddon-64.png",
    "64": "/data/myaddon-64.png",
    "64": "./data/myaddon-64.png",
},
...

Absolutely none of the techniques described on any MDN article, nor in any SO answer, have worked, not even once. In all cases, Firefox will pull an icon from the net on startup.

For some reason, what was a trivial task in XUL (and indeed one of the most basic tasks in creating an add-on) seems wildly inconsistent and nearly impossible to achieve with jpm, with everyone swearing by one of about 20-30 different specific techniques which work for only certain versions of the tool or browsers.

Likewise, I can't even get icons to work in Action Button widget, but I will ask that separately. Seemed to work with jpm run, but not at all with jpm xpi.

I am using jpm 1.0.7 pulled from git master only a few days ago as of time of writing.

2 Answers2

1

Found the problem with my code.

"icons": {
     ^ -- herein lies the problem

This should have been icon singular. The various other confusing options for specifying the location of the files remain, yet what seems to work the simplest and cleanest (at present) is a relative path.

"icon": {
    "16": "data/icon-16.png",
    "32": "data/icon-32.png",
    "48": "data/icon-48.png",
    "64": "data/icon-64.png"
},

Then the jpm scripts (lib/rdf.js:68-69,92) will construct a proper resource:// line in the install.rdf from values found in icon.

          <em:iconURL>resource://GUID/data/icon-48.png</em:iconURL>
          <em:icon64URL>resource://GUID/data/icon-64.png</em:icon64URL>
  • Either it didn't let me pick my own answer to my question right away, or I was waiting to see if I had really answered it correctly. In either case, I forgot to accept the answer. This seems to have worked. Some confusion with documentation. Thanks for the reminder. –  Jul 30 '16 at 17:50
0

Do not use package.json for Addon icon. Place icon.png and icon64.png files near package.json file File icon.png must have 48x48 dimensions and icon64.png must have 64x64 dimensions.

M.Onyshchuk
  • 165
  • 9
  • Thank you for the simple answer! This seems to have worked, and wasn't prominently documented anywhere on the MDN pages, nor on other answers to similar questions. The icon gets displayed and is not being pulled from the internet, which is exactly the behavior I was expecting. It is annoying though, because I use the same icons elsewhere and thus have to have redundant copies inside the `/data` location, because I can't access them in the root location. It is also confusing that there is no iconURL or icon64URL generated in the `install.rdf`. I will have to examine the jpm source closely. –  Jul 04 '16 at 11:23