# Recipe for building a python3 app (written using Kivy) for Android-28/NDK-17c.
# ASSUMES Ubantu 18.04 CLEAN INSTALL
# Tested with Windows Subystem for Linux Ubantu 18.04 and Android Pie
#
sudo apt-get update
sudo apt-get upgrade
### Install Apt dependencies
sudo apt-get install -y openjdk-8-jdk zip unzip virtualenv python3-pip
### Install Python dependencies
sudo -H pip3 install cython git+https://github.com/kivy/python-for-android.git
### Download Android Tools (ndk and sdk) , copy to <WHERE_EVER>
# https://developer.android.com/ndk/downloads/older_releases
# android-ndk-r17c-linux-x86_64.zip
# https://developer.android.com/studio/
# sdk-tools-linux-4333796.zip
### Install Android Tools
cd <WHERE_EVER>
unzip -q -d sdk sdk-tools-linux-4333796.zip
unzip -q android-ndk-r17c-linux-x86_64.zip
### Build Android Tools
cd <WHERE_EVER>/sdk/tools/bin
./sdkmanager "platforms;android-28"
./sdkmanager "build-tools;28.0.3"
### Install p4a Done
### Build App Configuration
cd <location of app main.py>
# Create a ".p4a" containing (replace text between and including <>)
# An app may need more options than these:
--dist_name=<XXX>
--private .
--package=com.<YYY>.<XYZ>
--name <ZZZ>
--bootstrap=sdl2
--requirements=python3,kivy
--arch=armeabi-v7a
--icon <ICON>.png
--sdk_dir <WHERE_EVER>/sdk
--ndk_dir <WHERE_EVER>/android-ndk-r17c
--android_api 28
--ndk_version 17c
--ndk-api 21
--version <0.0.0>
# Build .apk
# the first time this will take a while, and it is verbose
# Some stuff fails and recovers, so relax
p4a apk
# Bump the "--version" for each app update
### Workaround Issue #1327. Java heap issue - thanks JonasT
### Also add this line to .bashrc
export GRADLE_OPTS="-Xms1724m -Xmx5048m -Dorg.gradle.jvmargs='-Xms1724m -Xmx5048m'"
Perhaps something of this form will work for you?
The interesting thing about the 'python3' recipe is it downloads almost everything it needs into a virtual environment - which is why the user install is simple.
If one wants to see what it does, the the files are in /usr/local/lib/python3.6/dist-packages/pythonforandroid (your python may be different from 3.6)
tar xf private.mp3
-rwxrwxrwx 1 bobf bobf 3300 Dec 31 1979 AndroidManifest.xml
-rwxrwxrwx 1 bobf bobf 78172 Dec 31 1979 classes.dex
-rwxrwxrwx 1 bobf bobf 2360 Dec 31 1979 resources.arsc
META-INF:
total 12
-rwxrwxrwx 1 bobf bobf 1165 Dec 31 1979 CERT.RSA
-rwxrwxrwx 1 bobf bobf 2127 Dec 31 1979 CERT.SF
-rwxrwxrwx 1 bobf bobf 2065 Dec 31 1979 MANIFEST.MF
assets:
total 8020
-rwxrwxrwx 1 bobf bobf 8211856 Dec 31 1979 private.mp3
lib:
total 0
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 armeabi-v7a
res:
total 0
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 drawable
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 drawable-hdpi-v4
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 drawable-mdpi-v4
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 drawable-xhdpi-v4
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 drawable-xxhdpi-v4
drwxrwxrwx 1 bobf bobf 512 Dec 2 14:07 layout
Specifying the the app uses the "android" package results in a p4a crash. Has been posted as p4a issue #1504
--requirements=python3,kivy,android
Crashes at:
File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py", line 33, in prebuild_arch
bootstrap = bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
The workaround is to edit (you need sudo, and your python version may be different):
/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py
Remove that utf-8 decoding on line 33:
#bootstrap = bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')
bootstrap = bootstrap_name = self.ctx.bootstrap.name
sudo pip3 uninstall python-for-android
sudo -H pip3 install git+https://github.com/kivy/python-for-android.git
p4a clean_all
./sdkmanager "platforms;android-28"
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/dd30868e-bd03-4145-8f63-a1df79fb5047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
### Download Android Tools (ndk and sdk) , copy to <WHERE_EVER>
apt-cache search libffilibffi-dev - Foreign Function Interface library (development files)libffi6 - Foreign Function Interface library runtimelibffi6-dbg - Foreign Function Interface library runtime (debug symbols)libalt-alien-ffi-system-perl - simplified alternative to Alien::FFI that uses system libffilibffi-checklib-perl - module to check availability of a library for FFIlibffi-platypus-perl - module to create Perl bindings to non-Perl libraries with FFIlibffindex0 - library for simple index/database for huge amounts of small fileslibffindex0-dev - library for simple index/database for huge amounts of small files (development)libjffi-java - Java Foreign Function Interfacelibjffi-jni - Java Foreign Function Interface (JNI library)
root@localhost:/home/trivia_game/trivia_app_v5# p4a apk[INFO]: Reading .p4a configuration[INFO]: Recipe kivy: version "master" requested[WARNING]: --ndk-version is deprecated and no longer necessary, the value you passed is ignored[INFO]: Will compile for the following archs: armeabi-v7a[INFO]: Getting Android API version from user argument: 28[INFO]: Available Android APIs are (28)[INFO]: Requested API target 28 is available, continuing.[INFO]: Getting NDK dir from from user argument[INFO]: Found NDK revision 17.2.4988734[INFO]: Getting NDK API version (i.e. minimum supported API) from user argument[INFO]: Found virtualenv at /usr/bin/virtualenv[INFO]: ccache is missing, the build will not be optimized in the future.[INFO]: Found the following toolchain versions: ['4.9'][INFO]: Picking the latest gcc toolchain, here 4.9[WARNING]: Missing executable: pkg-config is not installed[INFO]: No existing dists meet the given requirements!
[INFO]: No dist exists that meets your requirements, so one will be built.
[INFO]: Found a single valid recipe set: ['constantly', 'hostpython3', 'incremental', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted'][INFO]: The selected bootstrap is sdl2[INFO]: # Creating dist with sdl2 bootstrap[INFO]: Dist will have name TriviaTV and requirements (python3, kivy, sqlite3, twisted, libffi)[INFO]: Dist contains the following requirements as recipes: ['hostpython3', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted'][INFO]: Dist will also contain modules (incremental, constantly) installed from pip[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Recipe build order is ['hostpython3', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted'][INFO]: The requirements (constantly, incremental) were not found as recipes, they will be installed with pip.[INFO]: # Downloading recipes[INFO]: Downloading hostpython3[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/hostpython3[INFO]: -> directory context /root/.local/share/python-for-android/packages/hostpython3[INFO]: -> running basename https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz[INFO]: hostpython3 download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading libffi[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/libffi[INFO]: -> directory context /root/.local/share/python-for-android/packages/libffi[INFO]: -> running basename https://github.com/libffi/libffi/archive/v3.2.1.tar.gz[INFO]: libffi download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading openssl[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/openssl[INFO]: -> directory context /root/.local/share/python-for-android/packages/openssl[INFO]: -> running basename https://www.openssl.org/source/openssl-1.1.1.tar.gz[INFO]: openssl download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading sdl2_image[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_image[INFO]: -> directory context /root/.local/share/python-for-android/packages/sdl2_image[INFO]: -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL...(and 20 more)[INFO]: sdl2_image download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading sdl2_mixer[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_mixer[INFO]: -> directory context /root/.local/share/python-for-android/packages/sdl2_mixer[INFO]: -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL...(and 20 more)[INFO]: sdl2_mixer download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading sdl2_ttf[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_ttf[INFO]: -> directory context /root/.local/share/python-for-android/packages/sdl2_ttf[INFO]: -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz[INFO]: sdl2_ttf download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading sqlite3[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/sqlite3[INFO]: -> directory context /root/.local/share/python-for-android/packages/sqlite3[INFO]: -> running basename https://www.sqlite.org/2016/sqlite-amalgamation-3150100.zip[INFO]: sqlite3 download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading python3[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/python3[INFO]: -> directory context /root/.local/share/python-for-android/packages/python3[INFO]: -> running basename https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz[INFO]: python3 download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading sdl2[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2[INFO]: -> directory context /root/.local/share/python-for-android/packages/sdl2[INFO]: -> running basename https://www.libsdl.org/release/SDL2-2.0.9.tar.gz[INFO]: sdl2 download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading setuptools[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/setuptools[INFO]: -> directory context /root/.local/share/python-for-android/packages/setuptools[INFO]: -> running basename https://pypi.python.org/packages/source/s/setuptools/...(and 21 more)[INFO]: setuptools download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading six[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/six[INFO]: -> directory context /root/.local/share/python-for-android/packages/six[INFO]: -> running basename https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz[INFO]: six download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading pyjnius[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/pyjnius[INFO]: -> directory context /root/.local/share/python-for-android/packages/pyjnius[INFO]: -> running basename https://github.com/kivy/pyjnius/archive/6553ad4.zip[INFO]: pyjnius download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading zope_interface[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/zope_interface[INFO]: -> directory context /root/.local/share/python-for-android/packages/zope_interface[INFO]: -> running basename https://pypi.python.org/packages/source/z/zope.interf...(and 31 more)[INFO]: zope_interface download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading android[INFO]: Skipping android download as no URL is set[INFO]: Downloading kivy[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/kivy[INFO]: -> directory context /root/.local/share/python-for-android/packages/kivy[INFO]: -> running basename https://github.com/kivy/kivy/archive/master.zip[INFO]: kivy download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Downloading twisted[INFO]: -> running mkdir -p /root/.local/share/python-for-android/packages/twisted[INFO]: -> directory context /root/.local/share/python-for-android/packages/twisted[INFO]: -> running basename https://github.com/twisted/twisted/archive/twisted-17.9.0.tar.gz[INFO]: twisted download already cached, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: # Building all recipes for arch armeabi-v7a[INFO]: # Unpacking recipes[INFO]: Unpacking hostpython3 for armeabi-v7a[INFO]: -> running basename https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop[INFO]: hostpython3 is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking libffi for armeabi-v7a[INFO]: -> running basename https://github.com/libffi/libffi/archive/v3.2.1.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a__ndk_target_21[INFO]: libffi is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking openssl for armeabi-v7a[INFO]: -> running basename https://www.openssl.org/source/openssl-1.1.1.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/openssl/armeabi-v7a__ndk_target_21[INFO]: openssl is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking sdl2_image for armeabi-v7a[INFO]: -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL...(and 20 more)[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni[INFO]: sdl2_image is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking sdl2_mixer for armeabi-v7a[INFO]: -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL...(and 20 more)[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni[INFO]: sdl2_mixer is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking sdl2_ttf for armeabi-v7a[INFO]: -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni[INFO]: sdl2_ttf is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking sqlite3 for armeabi-v7a[INFO]: -> running basename https://www.sqlite.org/2016/sqlite-amalgamation-3150100.zip[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/sqlite3/armeabi-v7a__ndk_target_21[INFO]: sqlite3 is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking python3 for armeabi-v7a[INFO]: -> running basename https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21[INFO]: python3 is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking sdl2 for armeabi-v7a[INFO]: -> running basename https://www.libsdl.org/release/SDL2-2.0.9.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni[INFO]: sdl2 is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking setuptools for armeabi-v7a[INFO]: -> running basename https://pypi.python.org/packages/source/s/setuptools/...(and 21 more)[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21[INFO]: setuptools is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking six for armeabi-v7a[INFO]: -> running basename https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/six-python3/armeabi-v7a__ndk_target_21[INFO]: six is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking pyjnius for armeabi-v7a[INFO]: -> running basename https://github.com/kivy/pyjnius/archive/6553ad4.zip[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/pyjnius-python3-sdl2/armeabi-v7a__ndk_target_21[INFO]: pyjnius is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking zope_interface for armeabi-v7a[INFO]: -> running basename https://pypi.python.org/packages/source/z/zope.interf...(and 31 more)[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/zope_interface-python3/armeabi-v7a__ndk_target_21[INFO]: zope_interface is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: -> running rm -rf /root/.local/share/python-for-android/build/other_build...(and 57 more)[INFO]: -> running cp -a /usr/local/lib/python3.6/dist-packages/pythonforandroid/...(and 132 more)[INFO]: Unpacking kivy for armeabi-v7a[INFO]: -> running basename https://github.com/kivy/kivy/archive/master.zip[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/kivy-python3-sdl2/armeabi-v7a__ndk_target_21[INFO]: kivy is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Unpacking twisted for armeabi-v7a[INFO]: -> running basename https://github.com/twisted/twisted/archive/twisted-17.9.0.tar.gz[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/twisted-python3/armeabi-v7a__ndk_target_21[INFO]: twisted is already unpacked, skipping[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: # Prebuilding recipes[INFO]: Prebuilding hostpython3 for armeabi-v7a[INFO]: hostpython3 has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding libffi for armeabi-v7a[INFO]: libffi has no prebuild_armeabi_v7a, skipping[INFO]: Applying patches for libffi[armeabi-v7a][INFO]: libffi already patched, skipping[INFO]: Prebuilding openssl for armeabi-v7a[INFO]: openssl has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding sdl2_image for armeabi-v7a[INFO]: sdl2_image has no prebuild_armeabi_v7a, skipping[INFO]: Applying patches for sdl2_image[armeabi-v7a][INFO]: sdl2_image already patched, skipping[INFO]: Prebuilding sdl2_mixer for armeabi-v7a[INFO]: sdl2_mixer has no prebuild_armeabi_v7a, skipping[INFO]: Applying patches for sdl2_mixer[armeabi-v7a][INFO]: sdl2_mixer already patched, skipping[INFO]: Prebuilding sdl2_ttf for armeabi-v7a[INFO]: sdl2_ttf has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding sqlite3 for armeabi-v7a[INFO]: sqlite3 has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding python3 for armeabi-v7a[INFO]: python3 has no prebuild_armeabi_v7a, skipping[INFO]: Applying patches for python3[armeabi-v7a][INFO]: python3 already patched, skipping[INFO]: Prebuilding sdl2 for armeabi-v7a[INFO]: sdl2 has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding setuptools for armeabi-v7a[INFO]: setuptools has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding six for armeabi-v7a[INFO]: six has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding pyjnius for armeabi-v7a[INFO]: pyjnius has no prebuild_armeabi_v7a, skipping[INFO]: Applying patches for pyjnius[armeabi-v7a][INFO]: pyjnius already patched, skipping[INFO]: Prebuilding zope_interface for armeabi-v7a[INFO]: zope_interface has no prebuild_armeabi_v7a, skipping[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/zope_interface-python3/armeabi-v7a__ndk_target_21/zope_interface[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Applying patches for zope_interface[armeabi-v7a][INFO]: zope_interface already patched, skipping[INFO]: Prebuilding android for armeabi-v7a[INFO]: android has no prebuild_armeabi_v7a, skipping[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/android-python3-sdl2/armeabi-v7a__ndk_target_21/android[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Prebuilding kivy for armeabi-v7a[INFO]: kivy has no prebuild_armeabi_v7a, skipping[INFO]: Prebuilding twisted for armeabi-v7a[INFO]: twisted has no prebuild_armeabi_v7a, skippingShould remove twisted tests etc. here, but skipping for now[INFO]: Applying patches for twisted[armeabi-v7a][INFO]: twisted already patched, skipping[INFO]: # Building recipes[INFO]: Building hostpython3 for armeabi-v7a[INFO]: Skipping hostpython3 (3.7.1) build, as it has already been completed[INFO]: Building libffi for armeabi-v7a[INFO]: libffi said it is already built, skipping[INFO]: Building openssl for armeabi-v7a[INFO]: openssl said it is already built, skipping[INFO]: Building sdl2_image for armeabi-v7a[INFO]: Building sdl2_mixer for armeabi-v7a[INFO]: Building sdl2_ttf for armeabi-v7a[INFO]: Building sqlite3 for armeabi-v7a[INFO]: sqlite3 said it is already built, skipping[INFO]: Building python3 for armeabi-v7a[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21/python3/android-build[WARNING]: Doing some hacky stuff to link properly[INFO]: -> running cp /home/project/android-ndk-r17c/platforms/android-21/arch-ar...(and 26 more)[INFO]: -> running cp /home/project/android-ndk-r17c/platforms/android-21/arch-ar...(and 24 more)[WARNING]: lld not found, linking without it. Consider installing lld if linker errors occur.[INFO]: Activating flags for sqlite3[INFO]: Activating flags for libffi[INFO]: Activating flags for openssl[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Building sdl2 for armeabi-v7a[INFO]: -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni[INFO]: -> running ndk-build V=1[INFO]: <- directory context /home/trivia_game/trivia_app_v5[INFO]: Building setuptools for armeabi-v7a[INFO]: setuptools apparently isn't already in site-packages[INFO]: Installing setuptools into site-packages[INFO]: -> directory context /root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools[INFO]: -> running python setup.py install -O2 --root=/root/.local/share/python-f...(and 57 more)working: ModuleNotFoundError: No module named '_ctypes' Exception in thread background thread for pid 19929:
Traceback (most recent call last):File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_innerself.run()File "/usr/lib/python3.6/threading.py", line 864, in runself._target(*self._args, **self._kwargs)File "/usr/local/lib/python3.6/dist-packages/sh.py", line 1540, in wrapfn(*args, **kwargs)File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2459, in background_threadhandle_exit_code(exit_code)File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2157, in fnreturn self.command.handle_command_exit_code(exit_code)File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_coderaise exc
sh.ErrorReturnCode_1:RAN: /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python setup.py install -O2 --root=/root/.local/share/python-for-android/build/python-installs/TriviaTV --install-lib=.STDOUT:
Traceback (most recent call last):
File "setup.py", line 11, in <module>import setuptoolsFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/__init__.py", line 14, in <module>from setuptools.dist import Distribution, FeatureFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/dist.py", line 25, in <module>from setuptools import windows_supportFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/windows_support.py", line 2, in <module>import ctypesFile "/root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/ctypes/__init__.py", line 7, in <module>from _ctypes import Union, Structure, ArrayModuleNotFoundError: No module named '_ctypes'
STDERR:Traceback (most recent call last):File "/usr/local/bin/p4a", line 11, in <module>load_entry_point('python-for-android==0.7.1', 'console_scripts', 'p4a')()
File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 1075, in mainToolchainCL()File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 577, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 151, in wrapper_funcbuild_dist_from_args(ctx, dist, args)
File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 200, in build_dist_from_argsbuild_recipes(build_order, python_modules, ctx)File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/build.py", line 562, in build_recipesrecipe.build_arch(arch)File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipe.py", line 834, in build_archself.install_python_package(arch)File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipe.py", line 855, in install_python_package_env=hpenv, *self.setup_extra_args)
File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/logger.py", line 178, in shprintfor line in output:File "/usr/local/lib/python3.6/dist-packages/sh.py", line 863, in nextself.wait()File "/usr/local/lib/python3.6/dist-packages/sh.py", line 792, in waitself.handle_command_exit_code(exit_code)File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_coderaise exc
sh.ErrorReturnCode_1:RAN: /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python setup.py install -O2 --root=/root/.local/share/python-for-android/build/python-installs/TriviaTV --install-lib=.STDOUT:
Traceback (most recent call last):
File "setup.py", line 11, in <module>import setuptoolsFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/__init__.py", line 14, in <module>from setuptools.dist import Distribution, FeatureFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/dist.py", line 25, in <module>from setuptools import windows_supportFile "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/windows_support.py", line 2, in <module>import ctypesFile "/root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/ctypes/__init__.py", line 7, in <module>from _ctypes import Union, Structure, ArrayModuleNotFoundError: No module named '_ctypes'STDERR:
This may also be an issue:
[WARNING]: Missing executable: pkg-config is not installed
The trick is to try and figure out what each line of the log file might mean,pay particular attention to : error, warning and traceback.The rest is just a learning curve.
[WARNING]: lld not found, linking without it. Consider installing lld if linker errors occur.
ModuleNotFoundError: No module named '_ctypes'
sudo apt install build-essential
Your sys admin will give you better advice on issues like this.
Wow, you found an old post. But is still mostly valid.
I currently use python-for-android version 2019.8.9 , this was the latest version last time I checked.
I now use arm64, this is my current .p4a template:
--dist_name=<XXX>
--private .
--package=com.<YYY>.<XYZ>
--name <ZZZ>
--requirements=python3,kivy
--arch=arm64-v8a
--orientation sensor
--icon <ICON>.png
--sdk_dir <WHERE_EVER>/sdk
--ndk_dir <WHERE_EVER>/android-ndk-r17c
--android_api 29
--ndk-api 21
--version <0.0.0>
I now use sdk 29, same download file, but two lines in the instructions have changed to:
./sdkmanager "platforms;android-29"
./sdkmanager "build-tools;29.0.0"
APK size is about 12MB to 13MB - but this depends a little on the
size of the app code, and mostly on the external python modules or data files used by
the app...... it is easy to test this for yourself.
pyjnius works but 1) there is no checking between python and java, 2)
you have to have understand the Android Java structure. Mistakes are
easy to make, start with small tests, check the result of autoclass()
for non-None. In the examples when is says ".renpy." replace this with
".kivy.". A short learning curve, crash and burn a few times then it
becomes easy. Really, start with small tests.
I don't use plyer, personal preference, because some of the functions (buzzer, camera, ...?) do not support the current Android API. Surprise, crash :( however I am told some plyer functions do work. Try small tests :)
I debug from Windows, first install Android Studio, then add this line to the PATH, then at a CMD prompt type adb <command>
C:\Users\<USERNAME>\AppData\Local\Android\sdk1\platform-tools\
Enjoy.
09-20 10:42:47.720 7717 7753 I python : Traceback (most recent call last):09-20 10:42:47.720 7717 7753 I python : File "/home/eugene/digs/main.py", line 54, in <module>09-20 10:42:47.721 7717 7753 I python : File "jnius/jnius_export_class.pxi", line 1034, in jnius.jnius.JavaMultipleMethod.__call__09-20 10:42:47.721 7717 7753 I python : jnius.jnius.JavaException: No methods matching your arguments, available: ['(ILjava/lang/String;JLandroid/media/AudioAttributes;)V', '(ILjava/lang/String;[JILandroid/media/AudioAttributes;)V']09-20 10:42:47.721 7717 7753 I python : Python for android ended.
09-20 11:05:04.837 9154 9188 I python : Traceback (most recent call last):09-20 11:05:04.837 9154 9188 I python : File "/home/eugene/digs/main.py", line 52, in <module>09-20 11:05:04.838 9154 9188 I python : AttributeError: 'NoneType' object has no attribute 'getSystemService'09-20 11:05:04.838 9154 9188 I python : Python for android ended.
what am I doing wrong?