Load local WebExtension issue, plz help!

Hello everyone, I’m an Android develoer.
when I used org.mozilla.geckoview:geckoview in the Android application to load html under local assets folder, I tried to call the WebExtensionController.install method to load a remote or local signed xpi file.

In the callback of onInstallPrompt, I manually returned GeckoResult.allow()

The log shows that the extension was installed successfully, similar to
Extension installed: WebExtension {location=resource://android/assets/aaa.xpi, id=messaging2@example.com, flags=0},

but this flags=0 means that I cannot Call browser.runtime.connectNative("xxx")

I have already specified the required permissions when making xpi in the manifest.json

"permissions": [

The strange thing is that if I directly use the source code for making xpi, this problem will not occur.

It appears that GeckoView only exposes native messaging to built in extensions. This page from the GeckoView docs shows how to use nativeMessaging in a GeckoView extension, but all the examples they provide use either installBuiltIn() or ensureBuiltIn() to install the extension.

Digging a bit deeper, I found a comment on the installBuiltIn() method that states:

Built-in extensions have access to native messaging, don’t need to be signed and are installed from a folder in the APK instead of a .xpi bundle.

1 Like