kivy_buildozer
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
kivy_2020_hello_world [2019/12/19 10:33] – [Kivy 2020: Buildozer pour compiler une application Android en python] serge | kivy_buildozer [2022/09/14 09:39] (Version actuelle) – [Venv] serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Kivy 2020: Buildozer pour compiler une application Android en python ====== | + | ====== Kivy: Buildozer pour compiler une application Android en python ====== |
<WRAP center round box 60% centeralign> | <WRAP center round box 60% centeralign> | ||
- | **... {{tagpage> | + | **{{tagpage> |
- | **... {{tagpage> | + | **[[http:// |
- | **...** | + | |
</ | </ | ||
+ | <WRAP center round box 40% centeralign> | ||
+ | **[[les_pages_kivy_en_details|Les pages Kivy en détails]]** | ||
+ | </ | ||
+ | <WRAP center round box 60% centeralign> | ||
+ | **Generic Python packager for Android and iOS** | ||
+ | </ | ||
+ | =====Ressources===== | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | |||
+ | |||
+ | =====Utilisation sur Debian 11 Bullseye===== | ||
+ | ====Dépendances==== | ||
+ | sudo apt install libsdl2-dev zlib1g-dev pkg-config autoconf automake cmake dkms libtool libsdl2-2.0-0 ccache unzip ffmpeg libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libswscale-dev libncurses5: | ||
+ | | ||
+ | ===OpenJDK=== | ||
+ | Pour connaître votre version actuelle | ||
+ | java -version | ||
+ | | ||
+ | Pour avoir la liste des versions installées | ||
+ | sudo update-java-alternatives --list | ||
+ | | ||
+ | Pour changer de version | ||
+ | sudo update-alternatives --config java | ||
+ | |||
+ | Il faut la version 11 | ||
+ | sudo apt install openjdk-11-jdk openjdk-11-source | ||
+ | ====Venv==== | ||
+ | **C' | ||
+ | Dans le dossier du venv existant: | ||
+ | <code bash> | ||
+ | source mon_env/ | ||
+ | python3 -m pip install buildozer setuptools cython | ||
+ | buildozer init | ||
+ | | ||
+ | File buildozer.spec created, ready to customize! | ||
+ | | ||
+ | toto@debian:/ | ||
+ | (mon_env) toto@debian:/ | ||
+ | |||
+ | (mon_env) toto@debian:/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | =====Le programme python kivy Hello world===== | ||
+ | |||
+ | * **[[https:// | ||
- | La page plus ancienne **Kivy Comment créer une application android en python** est en archive. | ||
- | =====Le programme python kivy===== | ||
<file python hello_world.py> | <file python hello_world.py> | ||
#! / | #! / | ||
Ligne 28: | Ligne 72: | ||
=====Compilation avec Buildozer===== | =====Compilation avec Buildozer===== | ||
- | ====Instalation==== | + | La page plus ancienne **Kivy Comment créer une application android en python** est en [[archives/ |
+ | ====Installation==== | ||
+ | Des ressources suffisantes mais peut-être pas necéssaires ! | ||
+ | <code text> | ||
+ | sudo dpkg --add-architecture i386 | ||
+ | sudo apt-get update | ||
+ | sudo apt-get install libsdl2-dev zlib1g-dev pkg-config autoconf automake cmake dkms libtool libsdl2-2.0-0 ccache openjdk-11-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: | ||
+ | | ||
+ | sudo pip3 install jinja2 appdirs sh colorama setuptools cython | ||
+ | sudo pip3 install pygame kivy buildozer pyjnius | ||
+ | </ | ||
+ | =====Utilisation===== | ||
+ | Le fichier principal qui lance kivy doit s' | ||
+ | Dans le dossier du projet: | ||
+ | buildozer init | ||
+ | crée le fichier buildozer.spec | ||
- | sudo pip3 install | + | ====buildozer.spec==== |
+ | Il faut définir une version pour l' | ||
- | =====Des problèmes | + | ===Le buildozer.spec du hello world=== |
- | ===openjdk 11 vs 8=== | + | <code python> |
- | Ce problème se retrouve identiquement sur une Xubuntu18.04 ! | + | [app] |
+ | title = My Application | ||
+ | package.name = myapp | ||
+ | package.domain = org.test | ||
+ | source.dir = . | ||
+ | source.include_exts | ||
+ | version | ||
+ | requirements | ||
+ | orientation | ||
+ | fullscreen | ||
+ | android.arch = armeabi-v7a | ||
- | https:// | + | [buildozer] |
+ | log_level = 2 | ||
+ | warn_on_root = 1 | ||
+ | </code> | ||
- | sudo apt remove --purge openjdk-*-jdk | + | === Version Méthode 1 === |
- | sudo apt install openjdk-11-jdk | + | Cette ligne doit être la première ligne de code du fichier main.py; les versions seront gérées dans ce fichier. |
- | Désinstallation | + | < |
- | sudo apt install openjdk-11-source | + | < |
- | Suppression des .buildozer du home et du dossier, recompil | + | # (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) | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # (str) Application versioning (method 2) | ||
+ | version = 1.2.0 | ||
+ | </ | ||
+ | |||
+ | ====Compilation==== | ||
+ | buildozer -v android debug | ||
+ | |||
+ | Le *.apk sera dans ./bin | ||
+ | |||
+ | =====openjdk 11 vs 8===== | ||
+ | ====L' | ||
+ | java.lang.NoClassDefFoundError: | ||
+ | |||
+ | < | ||
+ | # Installing/ | ||
+ | # Run '/ | ||
+ | # Cwd / | ||
+ | Exception in thread " | ||
+ | at com.android.repository.api.SchemaModule$SchemaModuleVersion.< | ||
+ | at com.android.repository.api.SchemaModule.< | ||
+ | at com.android.sdklib.repository.AndroidSdkHandler.< | ||
+ | at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java: | ||
+ | at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java: | ||
+ | Caused by: java.lang.ClassNotFoundException: | ||
+ | at java.base/ | ||
+ | at java.base/ | ||
+ | at java.base/ | ||
+ | ... 5 more | ||
+ | # Command failed: / | ||
+ | </ | ||
+ | |||
+ | ====Issue 862==== | ||
+ | Aucunes des solutions proposées par **https:// | ||
+ | |||
+ | Les recherches avec ce message d' | ||
+ | |||
+ | ====Nous utiliserons la version 8: facile !==== | ||
Installation de openjdk8: https:// | Installation de openjdk8: https:// | ||
wget -qO - https:// | wget -qO - https:// | ||
Ligne 55: | Ligne 178: | ||
java -version | java -version | ||
sudo update-alternatives --config java | sudo update-alternatives --config java | ||
- | + | Choisir la version 8 ! | |
- | + | ||
- | ===Building openssl for armeabi-v7a=== | + | |
- | sudo apt-get install libncurses5-dev libncursesw5-dev | + | |
- | sudo apt-get install libtinfo5 | + | |
=====Et à la fin c'est l' | =====Et à la fin c'est l' | ||
Victoire ! Une application qui marche ! | Victoire ! Une application qui marche ! | ||
- | {{tag>kivy_2020 | + | La compilation est longue, quelques heures, quelques Go téléchargés. Une recompilation suite à une nouvelle version serait bien sûr rapide (10 secondes). |
+ | |||
+ | 13 Mo pour une application qui ne fait rien: **{{ media_09: | ||
+ | |||
+ | Lorsque la compilation fini sur une erreur, je fais table rase: suppression des .android, .buildozer du home et du dossier du projet. | ||
+ | |||
+ | ====Deboggage sur Android==== | ||
+ | * [[https:// | ||
+ | < | ||
+ | sudo apt-get install adb | ||
+ | adb root | ||
+ | adb shell | ||
+ | kminilte:/ | ||
+ | </ | ||
+ | |||
+ | {{tag> |
kivy_buildozer.txt · Dernière modification : 2022/09/14 09:39 de serge