From fb3db597b11daf0bd9a0b4f14f8693ae202b1c99 Mon Sep 17 00:00:00 2001 From: Julian-o Date: Sat, 11 Nov 2023 04:00:20 +1100 Subject: [PATCH 1/3] Introduce FAQ Future work: * Remove much of same info from trouble-shooting section. * Remove duplicate info from Kivy framework FAQ. * Link to this from Kivy framework FAQ. --- FAQ.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 FAQ.md diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000000..f636201984 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,91 @@ +# FAQ for python-for-android (p4a) + +## Introduction + +[python-for-android](https://python-for-android.readthedocs.io/) is an open +source build tool to let you package Python code into standalone android APKs. +These can be passed around, installed, or uploaded to marketplaces such as the +Play Store just like any other Android app. + +### Sibling Projects: + +This tool was originally developed for apps produced with +the [Kivy framework](https://github.com/kivy/kivy), and is +managed by the same team. However, it can be used to build other types of Python +apps for Android. + +p4a is often used in conjunction +with [Buildozer](https://github.com/kivy/buildozer), which can download, install +and keep up-to-date any necessary prerequisites (including p4a itself), for a +number of target platforms, using a specification file to define the build. + +### Is it possible to have a kiosk app on Android? + +Thomas Hansen wrote a detailed answer +on [the kivy-users mailing list](https://groups.google.com/d/msg/kivy-users/QKoCekAR1c0/yV-85Y_iAwoJ) + +Basically, you need to root the device, remove the SystemUI package, add some +lines to the xml configuration, and you're done. + +### Common Errors + +The following are common problems and resolutions that users have reported. + +#### AttributeError: ‘AnsiCodes’ object has no attribute ‘LIGHTBLUE_EX’ + +This occurs if your version of `colorama` is too low, install version 0.3.3 or +higher. + +If you install python-for-android with pip or via setup.py, this dependency +should be taken care of automatically. + +#### AttributeError: ‘Context’ object has no attribute ‘hostpython’ + +This is a known bug in some releases. To work around it, add your python +requirement explicitly, e.g. `--requirements=python3,kivy`. This also applies +when using buildozer, in which case add python3 to your buildozer.spec +requirements. + +#### linkname too long + +This can happen when you try to include a very long filename, which doesn’t +normally happen but can occur accidentally if the p4a directory contains a +`.buildozer` directory that is not excluded from the build (e.g. if buildozer +was previously used). Removing this directory should fix the problem, and is +desirable anyway since you don’t want it in the APK. + +#### Requested API target 19 is not available, install it with the SDK android tool + +This means that your SDK is missing the required platform tools. You need to +install the `platforms;android-19` package in your SDK, using the android or +sdkmanager tools (depending on SDK version). + +If using buildozer this should be done automatically, but as a workaround you +can run these from `~/.buildozer/android/platform/android-sdk-20/tools/android`. + +#### ModuleNotFoundError: No module named ‘_ctypes’ + +You do not have the libffi headers available to python-for-android, so you need +to install them. On Ubuntu and derivatives these come from the `libffi-dev` +package. + +After installing the headers, clean the build (p4a clean builds, or with +buildozer delete the .buildozer directory within your app directory) and run +python-for-android again. + +#### SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) +Your hostpython3 was compiled without SSL support. You need to install the SSL +development files before rebuilding the hostpython3 recipe. Remember to always +clean the build before rebuilding (`p4a clean builds`, or with buildozer `buildozer +android clean`). + +On Ubuntu and derivatives: + + apt install libssl-dev + p4a clean builds # or with: buildozer `buildozer android clean + +On macOS: + + brew install openssl + sudo ln -sfn /usr/local/opt/openssl /usr/local/ssl + p4a clean builds # or with: buildozer `buildozer android clean From 3b5de7df41e3a71f70c1fb61dfe247fd203fd4fb Mon Sep 17 00:00:00 2001 From: Julian Date: Sat, 11 Nov 2023 14:20:24 +1100 Subject: [PATCH 2/3] Apply suggestions from code review Still to do: Remove obsolete section. Co-authored-by: Mirko Galimberti --- FAQ.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/FAQ.md b/FAQ.md index f636201984..e04c2e5497 100644 --- a/FAQ.md +++ b/FAQ.md @@ -3,7 +3,7 @@ ## Introduction [python-for-android](https://python-for-android.readthedocs.io/) is an open -source build tool to let you package Python code into standalone android APKs. +source build tool to let you package Python code into standalone Android artifacts (APKs, AABs, AARs). These can be passed around, installed, or uploaded to marketplaces such as the Play Store just like any other Android app. @@ -31,13 +31,6 @@ lines to the xml configuration, and you're done. The following are common problems and resolutions that users have reported. -#### AttributeError: ‘AnsiCodes’ object has no attribute ‘LIGHTBLUE_EX’ - -This occurs if your version of `colorama` is too low, install version 0.3.3 or -higher. - -If you install python-for-android with pip or via setup.py, this dependency -should be taken care of automatically. #### AttributeError: ‘Context’ object has no attribute ‘hostpython’ @@ -54,14 +47,14 @@ normally happen but can occur accidentally if the p4a directory contains a was previously used). Removing this directory should fix the problem, and is desirable anyway since you don’t want it in the APK. -#### Requested API target 19 is not available, install it with the SDK android tool +#### Requested API target XX is not available, install it with the SDK android tool This means that your SDK is missing the required platform tools. You need to -install the `platforms;android-19` package in your SDK, using the android or +install the `platforms;android-XX` package in your SDK, using the android or sdkmanager tools (depending on SDK version). If using buildozer this should be done automatically, but as a workaround you -can run these from `~/.buildozer/android/platform/android-sdk-20/tools/android`. +can run these from `~/.buildozer/android/platform/android-sdk-XX/tools/android` #### ModuleNotFoundError: No module named ‘_ctypes’ @@ -87,5 +80,4 @@ On Ubuntu and derivatives: On macOS: brew install openssl - sudo ln -sfn /usr/local/opt/openssl /usr/local/ssl p4a clean builds # or with: buildozer `buildozer android clean From aa40866d1d0209407fdaddd606a939f7d9bf7b66 Mon Sep 17 00:00:00 2001 From: Julian Date: Sat, 11 Nov 2023 14:23:04 +1100 Subject: [PATCH 3/3] Remove obsolete entry --- FAQ.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/FAQ.md b/FAQ.md index e04c2e5497..9e37084375 100644 --- a/FAQ.md +++ b/FAQ.md @@ -56,16 +56,6 @@ sdkmanager tools (depending on SDK version). If using buildozer this should be done automatically, but as a workaround you can run these from `~/.buildozer/android/platform/android-sdk-XX/tools/android` -#### ModuleNotFoundError: No module named ‘_ctypes’ - -You do not have the libffi headers available to python-for-android, so you need -to install them. On Ubuntu and derivatives these come from the `libffi-dev` -package. - -After installing the headers, clean the build (p4a clean builds, or with -buildozer delete the .buildozer directory within your app directory) and run -python-for-android again. - #### SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) Your hostpython3 was compiled without SSL support. You need to install the SSL development files before rebuilding the hostpython3 recipe. Remember to always