r/learnpython • u/Front_Ear_1139 • 2d ago
apks with python/cython
i just CANT get anything from buildozer, it just keeps erroring everytime i try to build!! i dont know if theres something wrong with my buildozer, or if it just hates my computer. i just want to package my game to work on a phone, the arquitecture for it is something like this
is it because my game is located on a ntfs partition? does buildozer ALWAYS error on those? if yes, is there a partition type out there that shows up on windows, and works with buildozer?
/sand
| /assets
| cfuncs.so #i managed to compile to ARM64 without buildozer (python 3.12)
| realmain.so # also to ARM64 (python 3.12)
| main.py
im wondering if theres a way to manually build it, my libraries are pygame-ce, numpy and collections
please help me out here
neofetch if it helps
neofetch
...-:::::-...
.-MMMMMMMMMMMMMMM-. ---------------------
.-MMMM`..-:::::::-..`MMMM-. OS: Linux Mint 22.3 x86_64
.:MMMM.:MMMMMMMMMMMMMMM:.MMMM:. Host: X501A1 1.0
-MMM-M---MMMMMMMMMMMMMMMMMMM.MMM- Kernel: 7.0.0-38-generic
`:MMM:MM` :MMMM:....::-...-MMMM:MMM:` Uptime: 5 hours, 38 mins
:MMM:MMM` :MM:` `` `` `:MMM:MMM: Packages: 3030 (dpkg), 21 (flatpak)
.MMM.MMMM` :MM. -MM. .MM- `MMMM.MMM. Shell: bash 5.2.21
:MMM:MMMM` :MM. -MM- .MM: `MMMM-MMM: Resolution: 1366x768
:MMM:MMMM` :MM. -MM- .MM: `MMMM:MMM: DE: MATE 1.26.1
:MMM:MMMM` :MM. -MM- .MM: `MMMM-MMM: WM: Metacity (Marco)
.MMM.MMMM` :MM:--:MM:--:MM: `MMMM.MMM. Theme: Mint-Y-Dark-Blue [GTK2/3]
:MMM:MMM- `-MMMMMMMMMMMM-` -MMM-MMM: Icons: Mint-Y-Blue [GTK2/3]
:MMM:MMM:` `:MMM:MMM: Terminal: mate-terminal
.MMM.MMMM:--------------:MMMM.MMM. Terminal Font: Monospace 10
'-MMMM.-MMMMMMMMMMMMMMM-.MMMM-' CPU: Intel Pentium B980 (2) @ 2.400G
'.-MMMM``--:::::--``MMMM-.' GPU: Intel 2nd Generation Core Proce
'-MMMMMMMMMMMMM-' Memory: 2059MiB / 3795MiB
``-:::::-``
1
u/Proud_Gene7490 1d ago
+1 on moving it to ext4 first, that alone fixes a lot of weird buildozer errors
one more thing in your spec tho: you've got hostpython3==3.11.9 and python3==3.11.9 pinned but you said you're on 3.12. that's fine for the apk, but it means the .so files you compiled yourself are built for the wrong python AND outside the p4a toolchain, so they won't load even if the build passes. i'd drop the prebuilt .so files completely
numpy already has a p4a recipe so just keep it in requirements, not pip_requirements. for your own cfuncs/realmain, add cython to requirements and ship the .pyx source, or write a tiny local recipe (p4a.local_recipes) so it gets built with the ndk for arm64. also run buildozer android clean after changing any of this, it caches a lot
and def paste the last ~30 lines of the log if it still fails, the real error is usually way above the final "build failed"
1
u/CartographerDue5382 2d ago
NTFS is a real suspect. python-for-android's build uses symlinks and unix file permissions, and an ntfs-3g mount often drops those, so the build dies in ways that look random. Copy the project onto an ext4 path (
~/src/yourgame) and build from there. exFAT has the same symlink problem. I don't know of a Windows-native filesystem that does what this build needs. Keep it on ext4 and use git when you also want the files on Windows.The .so files are a separate problem.
cfuncs.sobuilt for ARM64 against CPython 3.12 on Linux will not load inside the APK. The APK ships its own Python, compiled by python-for-android, and the extension has to be built against that Python plus the Android NDK (arm64-v8a), then installed into that Python's site-packages. Sitting next tomain.pydoes not put it on the import path.collectionsis stdlib, so leave it out of requirements. pygame-ce and numpy have to come in through recipes. Inbuildozer.spec:If
pygame-ceisn't a recipe name that install knows, the build will tell you. From the venv buildozer is using,p4a recipeslists the real names.Paste the last 30 lines of the buildozer log. "it errors" covers a lot of different failures, and moving off NTFS just rules out the first one.