Reputation: 3561
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?
Upvotes: 3
Views: 276
Reputation: 33296
Given that you already have completely different versions for desktop and Android, you should be able to use the use the [flags] in your chrome.manifest
to provide a different directory for the content
, or other type of entry, based on the application ID using the application=app-ID
flag. The application ID is different for Firefox for Android and Desktop Firefox.
The flags are explicitly there for you to be able to have different content based on the application (e.g. desktop/Android), the version of the application, the OS, the OS version, etc.
Example chrome.manifest
entries would be:
content myAddon chrome/content-desktop/ application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
content myAddon chrome/content-android/ application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
In the above example the URLs referencing chrome://myAddon/content
would come from the chrome/content-desktop/
directory for desktop Firefox and the chrome/content-android/
for Firefox on Android.
If you have content that is shared between applications, you could have an entry like:
content myAddonShared chrome/content-shared/
Because you are using the Add-on SDK, you may have a bit more trouble doing this. I suspect that there is no way to set cfx up to provide such entries, and that you will have to make them manually.
Upvotes: 1
Reputation: 3561
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
Upvotes: 3