When I show ApkPy to someone, the first question is almost always the same: how does this run Python on Android?
It doesn't. ApkPy reads writehere.py and writes Java and XML. The APK from apkpy run has activities, layouts, drawables and a manifest, the same as an app built by hand in Android Studio. There is no Python interpreter inside, no WebView, and no CPython compiled as a library.
I chose translation over embedding because of size. In the benchmark I published, the same 100-note app was 5.37 MiB in debug and 1.48 MiB in the signed release. With an interpreter inside, the starting point would be different. And because the generated code is plain Java, the camera and background audio are Android APIs, not bridges to them.
The cost shows up when I write Python ApkPy cannot translate yet. The build stops on that line and says what to write instead.
1.14.0, out on October 20, was mostly about that. Most of the Python people write every day now goes through: a, b = parts, for key, value in d.items(), items.pop(), sorted(), comprehensions inside functions, f-string widths ({n:05d}), *args, functions inside functions, recursion, try/except and for ... else.
Some of it was less visible than new syntax. The generated Java is now checked against CPython on the same inputs, accents and emoji included.
1.14.0 also tightened installation. apkpy setup now checks the sha256 of everything it downloads.
The Python that translates is listed on Compatibility and limits.
If you want to try it:
python -m pip install --upgrade apkpy
apkpy start hello
cd hello
python writehere.py
writehere.py opens the Previewer. apkpy run generates the Android project and builds a debug APK next to it.
Top comments (0)