Setting up a Cordova environment can be very challenging. There are a lot of components to install and to have configured just right.
Thanks to the great work of the community, it is possible to build apps inside a container. The container can be run inside Windows or in a Continuous Integration Pipeline.
For development purposes, it can be useful to connect the container to a real device. This article will show you how to set up an Android environment to build Cordova applications and have this deployed to a real device. This is achieved by creating a bridge through the container using the ADB command.
Step 1: Install Docker on your machine.
The process for this varies between platforms and is outside the scope of this article. For Windows Docker is best installed with Docker Desktop https://www.docker.com/products/docker-desktop/
Step 2: Install and ADB command on the host machine
If you have Android Studio installed, you probably already have the Android platform tools installed as well. If not either install Android Studio or install the tools directly from: https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Step 3: Run ADB server on the host machine
Plug in your phone to a USB socket and run:
adb -a nodaemon server start
Step 4: Install the Docker image
Run the following command to install the docker image:
docker build https://github.com/aaronfultonnz/cordova-android-development.git -t devandroid
Step 5: Run the docker image
docker run -it -v C:\path\to\src-cordova:/opt/src --rm devandroid cordova run android(update C:\path\to\src-cordova to the actual path of your app)
The docker container should detect your real device and deploy the app.