|
| 1 | +# FAQ for python-for-android (p4a) |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +[python-for-android](https://python-for-android.readthedocs.io/) is an open |
| 6 | +source build tool to let you package Python code into standalone Android artifacts (APKs, AABs, AARs). |
| 7 | +These can be passed around, installed, or uploaded to marketplaces such as the |
| 8 | +Play Store just like any other Android app. |
| 9 | + |
| 10 | +### Sibling Projects: |
| 11 | + |
| 12 | +This tool was originally developed for apps produced with |
| 13 | +the [Kivy framework](https://github.com/kivy/kivy), and is |
| 14 | +managed by the same team. However, it can be used to build other types of Python |
| 15 | +apps for Android. |
| 16 | + |
| 17 | +p4a is often used in conjunction |
| 18 | +with [Buildozer](https://github.com/kivy/buildozer), which can download, install |
| 19 | +and keep up-to-date any necessary prerequisites (including p4a itself), for a |
| 20 | +number of target platforms, using a specification file to define the build. |
| 21 | + |
| 22 | +### Is it possible to have a kiosk app on Android? |
| 23 | + |
| 24 | +Thomas Hansen wrote a detailed answer |
| 25 | +on [the kivy-users mailing list](https://groups.google.com/d/msg/kivy-users/QKoCekAR1c0/yV-85Y_iAwoJ) |
| 26 | + |
| 27 | +Basically, you need to root the device, remove the SystemUI package, add some |
| 28 | +lines to the xml configuration, and you're done. |
| 29 | + |
| 30 | +### Common Errors |
| 31 | + |
| 32 | +The following are common problems and resolutions that users have reported. |
| 33 | + |
| 34 | + |
| 35 | +#### AttributeError: ‘Context’ object has no attribute ‘hostpython’ |
| 36 | + |
| 37 | +This is a known bug in some releases. To work around it, add your python |
| 38 | +requirement explicitly, e.g. `--requirements=python3,kivy`. This also applies |
| 39 | +when using buildozer, in which case add python3 to your buildozer.spec |
| 40 | +requirements. |
| 41 | + |
| 42 | +#### linkname too long |
| 43 | + |
| 44 | +This can happen when you try to include a very long filename, which doesn’t |
| 45 | +normally happen but can occur accidentally if the p4a directory contains a |
| 46 | +`.buildozer` directory that is not excluded from the build (e.g. if buildozer |
| 47 | +was previously used). Removing this directory should fix the problem, and is |
| 48 | +desirable anyway since you don’t want it in the APK. |
| 49 | + |
| 50 | +#### Requested API target XX is not available, install it with the SDK android tool |
| 51 | + |
| 52 | +This means that your SDK is missing the required platform tools. You need to |
| 53 | +install the `platforms;android-XX` package in your SDK, using the android or |
| 54 | +sdkmanager tools (depending on SDK version). |
| 55 | + |
| 56 | +If using buildozer this should be done automatically, but as a workaround you |
| 57 | +can run these from `~/.buildozer/android/platform/android-sdk-XX/tools/android` |
| 58 | + |
| 59 | +#### SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) |
| 60 | +Your hostpython3 was compiled without SSL support. You need to install the SSL |
| 61 | +development files before rebuilding the hostpython3 recipe. Remember to always |
| 62 | +clean the build before rebuilding (`p4a clean builds`, or with buildozer `buildozer |
| 63 | +android clean`). |
| 64 | + |
| 65 | +On Ubuntu and derivatives: |
| 66 | + |
| 67 | + apt install libssl-dev |
| 68 | + p4a clean builds # or with: buildozer `buildozer android clean |
| 69 | + |
| 70 | +On macOS: |
| 71 | + |
| 72 | + brew install openssl |
| 73 | + p4a clean builds # or with: buildozer `buildozer android clean |
0 commit comments