I’m glad to share a new project called Python for Android. The goal of this project is to package your python application into an APK.
The project is under the umbrella of Kivy organization, but is not designed to be limited to Kivy only. Read the documentation to correctly install the NDK/SDK Android, and set the needed environment variables.
The packaging is done in 4 steps:
1. Ensure you have Android SDK/NDK downloaded and correctly installed
2. Ensure you have some environment set
3. Create a Python distribution containing the selected modules
4. Use that distribution to build an APK of your Python application
Creating the python distribution is as simple as that:
# create a simple distribution with python + PIL + Kivy ./distribute.sh -m "pil kivy" # create a distribution with python + openssl + pil + kivy ./distribute.sh -m "openssl pil kivy"
dist/default will be created, including the result of the whole arm compilation.
Available libraries as for today: jpeg pil png sdl sqlite3 pygame kivy android libxml2 libxslt lxml ffmpeg openssl.
The second step is a little bit harder, since you need to provide more information for Android:
cd dist/default ./build.py --package org.test.touchtracer --name touchtracer \ --version 1.0 --dir ~/code/kivy/examples/demo/touchtracer debug installd # --package: java name of your application # --name: title of your application # --version: version of your application # --dir: location of your application containing the main.py
Then you’ll get a nicely
- A blacklist.txt file that can be used to exclude files in the final APK
- Reusable distribution for other applications
- Modular recipes architecture
- Be able to build independents python distributions
- You need a main.py file that will be used for starting your application
- Only one java bootstrap available, using OpenGL ES 2.0.
- Only Kivy toolkit is working. I’m sure that other people can enhance it to add other toolkit recipes. But for example, pygame is not gonna to work because the android project is OpenGL ES 2.0: pygame drawing will not work.
I hope you’ll like it
We would like to thank Renpy / PGS4A for its initial pygame for android project
If you like my work, tip me!