Allowing PWA installation
First of all, install the Android debug bridge:
$ sudo apt install adb android-sdk-platform-tools-common
Start your Android emulator as usual, e.g.:
$ ~/Android/Sdk/emulator/emulator -avd Pixel_3a_API_30_x86
Only then, configure a reverse proxy on the bridge of the Android emulator that will forward localhost
HTTP requests to the appropriate port (e.g. 8000) of the localhost
server running on your host computer and vice versa:
$ adb reverse tcp:8000 tcp:8000
A progressive web application (PWA) being served on localhost:8000
or 127.0.0.1:8000
will be installable and connect to its service-worker.js
. Whereas PWA installation is not allowed from IP address 10.0.2.2
.
Caveat: adb reverse tcp:8000 tcp:8000
needs to be reissued after each Android emulator evocation.
Hence, a bash script to launch an Android emulator, followed by a reverse proxy, would look like this:
#!/usr/bin/env bash
$HOME/Android/Sdk/emulator/emulator -avd Pixel_3a_API_30_x86 > /dev/null 2>&1
adb reverse tcp:8000 tcp:8000