androidfirefoxfirefox-addon

How to install xpi files on firefox for android


I am developing a firefox addon that is meant to work on mobile only. To test it I want to download and install the xpi file on firefox for my android tablet.

This question wants me to open the file from firefox. I hosted the file on my httpd server but firefox only gives me the option to download the file, there is no prompt to install as an addon.

This question wants me to open the .xpi file with my file manager however in the "open with" prompt there is no firefox option. I have tried with both firefox and firefox nightly, but neither work.

My project consists of the manifest.json and a main.js zipped via dolphin. I just renamed the file from project.zip to project.xpi.

Because I want to test my project before publishing I don't want to use the addons page. How can I install an unsigned addon on firefox mobile.


Solution

  • This question is actually two questions in one.

    1. How to install a signed xpi from a file

    ā > Settings > About Firefox

    Tap the Firefox logo 5 times. Go back one screen. You'll have the ability to install extensions from files. This method only works for signed xpi files. (Supposedly the Nightly build is not less restrictive in that regard, but I don't use Nightly, so I have not verified it.)

    You can create private versions of extensions at AMO just to get them signed.

    2. How to install an unsigned xpi temporarily

    Reference: Getting started with web-ext

    2.1 One time

    Get (and install) the latest LTS version of NodeJS on your desktop, if you don't have it already. If you're only installing it for Android testing, you don't need to install stuff to compile native modules from C/C++ dynamically. (I didn't, and it works.)

    Install web-ext using NodeJS's npm.

    npm install --global web-ext (--global makes things easier)

    2.2 Each time

    Enable debugging in Firefox for Android (ā > Settings > Remote debugging via USB) and connect the Android device to the desktop using adb (Android debug bridge from Google's Android platform tools, which I'm going to consider outside the scope of this question).

    On your desktop, from the directory that has the unpacked (i.e., not zipped) extension to be tested, run web-ext. web-ext needs to be able to find manifest.json at the very least. It'll tell you about it if it can't.

    web-ext run --target=firefox-android --android-device=<device ID>

    The device ID supplied by web-ext run --target=firefox-android is the same one supplied by adb devices.

    2.3 Optional

    In addition to being able to use the extension on Android temporarily, you can also go to about:debugging on your desktop Firefox and enable remote debugging.

    On Setup, click Enable USB Devices, click Connect to connect to your device, then click your device. If you've ever run debugging on desktop extensions, things should look very familiar at this point. The debug console for the remote Android opens in a new tab on your desktop rather than as a popup, so that's different.