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édenteDernière révisionLes deux révisions suivantes | ||
kivy_2020_hello_world [2019/12/18 10:56] – [Instalationn] serge | kivy_buildozer [2022/09/14 09:38] – [Venv] serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Kivy 2020: Hello World ====== | + | ====== Kivy: Buildozer pour compiler une application Android en python |
+ | <WRAP center round box 60% centeralign> | ||
+ | **{{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==== | ||
+ | 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:// | ||
- | =====Le programme python kivy===== | ||
<file python hello_world.py> | <file python hello_world.py> | ||
#! / | #! / | ||
Ligne 22: | Ligne 71: | ||
=====Compilation avec Buildozer===== | =====Compilation avec Buildozer===== | ||
+ | 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 | ||
+ | |||
+ | ====buildozer.spec==== | ||
+ | Il faut définir une version pour l' | ||
+ | |||
+ | ===Le buildozer.spec du hello world=== | ||
+ | <code python> | ||
+ | [app] | ||
+ | title = My Application | ||
+ | package.name = myapp | ||
+ | package.domain = org.test | ||
+ | source.dir = . | ||
+ | source.include_exts = py, | ||
+ | version = 0.14 | ||
+ | requirements = python3, | ||
+ | orientation = portrait | ||
+ | fullscreen = 0 | ||
+ | android.arch = armeabi-v7a | ||
+ | |||
+ | [buildozer] | ||
+ | log_level = 2 | ||
+ | warn_on_root = 1 | ||
+ | </ | ||
+ | |||
+ | === 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. | ||
+ | < | ||
+ | < | ||
+ | # (str) Application versioning (method 1) | ||
+ | version.regex = __version__ = ['" | ||
+ | version.filename = %(source.dir)s/ | ||
+ | |||
+ | # (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:// | ||
+ | wget -qO - https:// | ||
+ | sudo add-apt-repository --yes https:// | ||
+ | sudo apt update -y | ||
+ | sudo apt install adoptopenjdk-8-hotspot -y | ||
+ | java -version | ||
+ | sudo update-alternatives --config java | ||
+ | Choisir la version 8 ! | ||
+ | |||
+ | =====Et à la fin c'est l' | ||
+ | Victoire ! Une application qui marche ! | ||
+ | |||
+ | 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). | ||
- | On repart sur une page blanche ! | + | 13 Mo pour une application qui ne fait rien: **{{ media_09:myapp-0.13-armeabi-v7a-debug.apk.zip |}}** |
- | ====Instalationn==== | + | |
- | sudo pip3 install buildozer pyjnuis | + | |
- | < | + | |
- | Collecting buildozer | + | |
- | Downloading https:// | + | |
- | 100% |████████████████████████████████| 112kB 387kB/s | + | |
- | Requirement already satisfied: pexpect in / | + | |
- | Requirement already satisfied: sh in / | + | |
- | Requirement already satisfied: virtualenv in / | + | |
- | Requirement already satisfied: ptyprocess> | + | |
- | Building wheels for collected packages: buildozer | + | |
- | Running setup.py bdist_wheel for buildozer ... done | + | |
- | Stored in directory: / | + | |
- | Successfully built buildozer | + | |
- | Installing collected packages: buildozer | + | |
- | Successfully installed buildozer-0.39 | + | |
- | Requirement already satisfied: pyjnius in / | + | |
- | Requirement already satisfied: six> | + | |
- | Requirement already satisfied: cython in / | + | |
- | </ | + | |
- | La version de cython est 0.29.2.2 | + | Lorsque la compilation fini sur une erreur, je fais table rase: suppression des .android, |
+ | ====Deboggage sur Android==== | ||
+ | * [[https:// | ||
+ | < | ||
+ | sudo apt-get install adb | ||
+ | adb root | ||
+ | adb shell | ||
+ | kminilte:/ | ||
+ | </ | ||
- | {{tag>kivy_2020}} | + | {{tag> |
kivy_buildozer.txt · Dernière modification : 2022/09/14 09:39 de serge