Search code examples
firefox-addonfirefox-addon-sdkfirefox-addon-restartless

jpm addon can't get icon to display in Addon Manager


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.


Solution

  • 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>