Search code examples
androidfirefoxfirefox-addonfirefox-addon-sdk

Creating a single Firefox extension compatible with both desktop and Android


I developed a simple Firefox extension that fully works on Firefox for desktop computers. The extension uses a few SDK elements which are incompatible with Firefox for Android, likePanel, making it incompatible on Android.

I created two separate versions of the extension - one for desktop computers, and another one without the incompatible SDK elements which is compatible with Android. Everything works, however when I came to submit both extensions to the Mozilla AMO they were rejected and I was asked to consolidate them into a single extension.

How can I create a Firefox extension which uses desktop-only SDK elements on desktop Firefox and does not use them on Firefox for Android?


Solution

  • I ended up researching the issue and decided to write a blog post about the solution: http://blog.danielmittelman.com/2014/12/developing-firefox-add-ons-with-desktop-and-android-compatibility/

    Here's the gist of it: There are SDK elements like panel or ui which are explicitly incompatible with Android. Ensuring compatibility with Android requires 3 steps:

    1) Using only necessary Android-incompatible SDK elements (what you don't need - don't use)

    2) Identifying the platform and using conditional statements to enable or disable potentially incompatible code

    3) Creating and/or running the add-on using the --force-mobile flag of cfx