Ceci est une ancienne révision du document !
Table des matières
Kivy: Buildozer pour créer une application Android avec un script python
Testé sur Debian Buster 10 Alpha 3 en Janvier 2019
Tout pour Debian Buster
sudo dpkg --add-architecture i386 sudo apt-get update
Logiciels
sudo apt-get install filezilla terminator caja-open-terminal grsync gparted geany geany-plugins ncdu git thunderbird blender inkscape vlc gimp audacity gdebi keepassxc geeqie blender simple-scan gnome-system-tools cups locales
System
sudo apt-get install libsdl2-dev zlib1g-dev pkg-config autoconf automake cmake dkms libtool libsdl2-2.0-0 ccache openjdk-8-jdk unzip ffmpeg libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev libgstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 zlib1g:i386 openjdk-8-source libssl-dev openssl gcc libpangoxft-1.0-0:i386 adb libtool build-essential python3-pip python3-dev python3-six libpython3-all-dev python3-all python3-all-dev python3-virtualenv virtualenv
N'existe plus
libav-tools
Python 3.7
Successfully installed
MarkupSafe-1.1.0 appdirs-1.4.3 colorama-0.4.1 jinja2-2.10 sh-1.12.14
sudo pip3 install jinja2 appdirs sh colorama setuptools
Building wheels for collected packages:
pyyaml, bs4, twisted, kivy, pyjnius, Kivy-Garden
Installing collected packages: pyyaml, soupsieve, beautifulsoup4, bs4, unidecode, lxml, attrs, Automat, PyHamcrest, constantly, hyperlink, incremental, zope.interface, twisted, numpy, opencv-python, Kivy-Garden, docutils, pygments, kivy, pygame, ptyprocess, pexpect, buildozer, pyjnius
Successfully installed
Automat-0.7.0 Kivy-Garden-0.1.4 PyHamcrest-1.9.0 attrs-18.2.0 beautifulsoup4-4.7.0 bs4-0.0.1 buildozer-0.37 constantly-15.1.0 docutils-0.14 hyperlink-18.0.0 incremental-17.5.0 kivy-1.10.1 lxml-4.2.6 numpy-1.15.4 opencv-python-3.4.5.20 pexpect-4.6.0 ptyprocess-0.6.0 pygame-1.9.4 pygments-2.3.1 pyjnius-1.1.4 pyyaml-3.13 soupsieve-1.6.1 twisted-18.9.0 unidecode-1.0.23 zope.interface-4.6.0
sudo pip3 install pyyaml bs4 unidecode lxml twisted numpy opencv-python kivy pygame buildozer pyjnius
Cython
Cython 3
Je ne comprends absolument pas pourquoi il faut cython en python3 et non pas cython3 !!!!!!!!!!!!!!!!!!
Cython
sudo pip install -U --force-reinstall Cython==0.27.3
https://github.com/kivy/buildozer/pull/757
cython==0.28.6
Contexte pour python 3
Hello World
- SDK 20 / API 24 / NDK 14b / Python 3.7
Ressources
Compilation d'un projet
Init
Ouvrir un terminal dans votre projet:
buildozer init
Edition de buildozer.spec
Points importants
# (str) Source code where the main.py live source.dir = . # (list) Source files to include (let empty to include all the files) source.include_exts = py,png,jpg,kv,atlas,ogg # (list) List of inclusions using pattern matching source.include_patterns = data/*.png, sound/*.ogg # (list) Application requirements # comma seperated e.g. requirements = sqlite3,kivy requirements = python3,kivy,openssl # (list) Permissions android.permissions = INTERNET,CHANGE_WIFI_MULTICAST_STATE,ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE # SDK 20 / API 26 / NDK 15c / Python 3.7 android.api = 26 android.sdk = 20 android.ndk = 15c android.sdk_path = /media/data/src_android/android-sdk-20 android.ndk_path = /media/data/src_android/android-ndk-r15c # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86 android.arch = armeabi-v7a
Version
Il faut définir une version pour l'application que vous compilez.
Version Méthode 1
Cette ligne doit être la première ligne de code du fichier main.py; les versions seront gérées dans ce fichier.
__version__ = '0.67'
# (str) Application versioning (method 1) version.regex = __version__ = ['"](.*)['"] version.filename = %(source.dir)s/main.py # (str) Application versioning (method 2) # version = 1.2.0
Version Méthode 2
La version est définie dans ce fichier buildozer.spec:
# (str) Application versioning (method 1) #version.regex = __version__ = ['"](.*)['"] #version.filename = %(source.dir)s/main.py # (str) Application versioning (method 2) version = 1.2.0
Compilation du apk
buildozer -v android debug
Quand ça plante
- buildozer android clean
- Détruire /home/user/.local/share/python-for-android
- .buildozer du home
- .buildozer de votre dossier
- .android du home
Debug de l'*.apk si l'application ne se lance pas
Suivre tout ce qui se passe sur le téléphone avec logcat
sudo apt-get install adb adb root adb shell kminilte:/sdcard/kivy/TapOSC $ logcat