Currently we use a containerized build for testing Python for Android recipes. Docker supports three big platforms either directly with the kernel or via using headless VirtualBox and a small distro to run itself on.
While this is not the actively supported way to build applications, if you are
willing to play with the approach, you can use the Dockerfile to build
the Docker image we use in .travis.yml for CI builds and create an Android
application with that in a container. This approach allows you to build Android
applications on all platforms Docker engine supports. These steps assume you
already have Docker preinstalled and set up.
Warning
This approach is highly space unfriendly! The more layers (commit) or
even Docker images (build) you create the more space it'll consume.
Within the Docker image there is Android + Crystax SDK and NDK + various
dependencies. Within the custom diff made by building the distribution
there is another big chunk of space eaten. The very basic stuff such as
a distribution with: CPython 3, setuptools, Python for Android android
module, SDL2 (+ deps), PyJNIus and Kivy takes almost 13 GB. Check your free
space first!
Clone the repository:
git clone https://github.com/kivy/python-for-android
Build the image with name
p4a:docker build --tag p4a .
Note
You need to be in the
python-for-androidfor the Docker build context and you can optionally use--fileflag to specify the path to theDockerfilelocation.Create a container from
p4aimage with copiedtestappsfolder in the image mounted to the same one in the cloned repo on the host:docker run \ --interactive \ --tty \ --volume ".../testapps":/home/user/testapps \ p4a sh -c '. venv/bin/activate \ && cd testapps \ && python setup_testapp_python3.py apk \ --sdk-dir $ANDROID_SDK_HOME \ --ndk-dir $ANDROID_NDK_HOME'Note
On Windows you might need to use quotes and forward-slash path for volume "/c/Users/.../python-for-android/testapps":/home/user/testapps
Warning
On Windows
gradlewwill attempt to use 'bashr' command which is a result of Windows line endings. For that you'll need to installdos2unixpackage into the image.Preserve the distribution you've already built (optional, but recommended):
docker commit $(docker ps --last=1 --quiet) my_p4a_dist
Find the
.APKfile on this location:ls -lah testapps