2
votes

I'm trying to write an Addon for Firefox. For this I'm using the Mozilla "Addon-SDK".

When i use the "jpm run" function all works well. But as soon as i package it to an xpi and install it, the icon wont show up in the toolbar. This seems to be a bug in the SDK.
I have tried various workaround solutions from other blog posts.

  • Editing package.json
  • renaming to "icon"
  • moving to data
  • Moving the icon to root
  • Absolute paths
  • editing the firefox version in rdf
  • debuging Index.js...

Here the most useful:

Firefox add-on : extension icon not showing
https://github.com/mozilla-jetpack/jpm/issues/197

Since Firefox 43 addons must be verifyed. I did this. I also disabled the function in about:config so i could try new versions faster. Still no luck.

Here is my code in index.js: Edited according to answer but still not working

    var button = buttons.ActionButton(
    {
      id: "MorastLink",
      label: "In den Morast",
      icon:
      {
        "16": "./images/icon16.png",
        "32": "./images/icon32.png",
        "64": "./images/icon64.png"
      },
    onClick: CopyToMorast
    });  

Here I also tried, moving the path, changing names, using absolute path...

And this is my package.json

    {
      "title": "Morast",
      "name": "morastaddon",
      "version": "0.1.4",
      "description": "An Addon to insert a \"Add to Morast\" button on distributer sites.",
      "main": "index.js",
      "author": "Lisa Austen",
      "icon": "ressource://@morastaddon/data/images/icon16.png",
      "icon64": "ressource://@morastaddon/data/images/icon64.png",
      "engines": {
      "firefox": ">=38.0a1",
      "fennec": ">=38.0a1" },
      "license": "MIT",
      "keywords": [
      "jetpack"
    ]
    }

https://github.com/LAusten/MorastAddon.git

1
I have tried that. It didn't workLisa Austen

1 Answers

1
votes

According to MDN, the icon path has to be relative to the data folder:

  • as a resource:// URL pointing at an icon file in your add-on's "data" directory, typically constructed using self.data.url(iconfile)

  • as a relative path: a string in the form "./iconfile", where "iconfile" is a relative path to the icon file beginning in your add-on's "data" directory

Example:

  icon:
  {
    "16": "./images/icon16.png",
    "32": "./images/icon32.png",
    "64": "./images/icon64.png"
  }