archives:kivy_buildozer_pour_creer_une_application_android_avec_un_script_python
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édenteProchaine révisionLes deux révisions suivantes | ||
kivy_buildozer_pour_creer_une_application_android_avec_un_script_python [2018/03/22 08:08] – serge | kivy_buildozer_pour_creer_une_application_android_avec_un_script_python [2019/01/06 10:17] – serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | =====Kivy: Buildozer pour créer une application Android avec un script python===== | + | ======Archive: Buildozer pour créer une application Android avec un script python====== |
- | **Cette page ne concerne que python 3.5** | + | <WRAP center round box 50% centeralign> |
+ | **{{tagpage> | ||
+ | </ | ||
- | Testé sur Debian | + | <WRAP center round info centeralign 50%> |
+ | **Testé sur Debian | ||
+ | </ | ||
- | ====== Installation de Kivy ====== | + | ===== Ressources |
+ | * [[https:// | ||
+ | * [[http:// | ||
- | Voir [[2_Kivy: | + | =====Tous les problèmes avec buildozer===== |
+ | ==== Cython ==== | ||
+ | **Je ne comprends absolument pas pourquoi il faut cython en python3 | ||
- | ====== Buildozer ====== | + | =====Contexte pour python 3===== |
+ | * **https:// | ||
- | ===== Installation ===== | + | * SDK 20 / API 24 / NDK 14b / Python 3.7 |
- | Dépendances suffisantes mais peut-être pas nécessaires: | + | ===== Compilation d'un projet ===== |
- | + | ||
- | Vérifier la version de cython à installer: | + | |
- | + | ||
- | * https:// | + | |
- | + | ||
- | < | + | |
- | sudo apt-get install python3-dev zlib1g-dev pkg-config python3-colorama python3-sh python3-appdirs python3-jinja2 python3-six | + | |
- | sudo pip3 install --upgrade cython==0.25 | + | |
- | </ | + | |
- | Les lib32 pour un 64 bits | + | |
- | + | ||
- | < | + | |
- | + | ||
- | sudo dpkg --add-architecture i386 | + | |
- | sudo apt-get update | + | |
- | sudo apt-get install build-essential ccache git libncurses5: | + | |
- | </ | + | |
- | Version en cours de dev: | + | |
- | + | ||
- | * https:// | + | |
- | + | ||
- | < | + | |
- | git clone https:// | + | |
- | cd buildozer/ | + | |
- | python3 setup.py build | + | |
- | sudo pip3 install -e . | + | |
- | </ | + | |
- | Version stable: | + | |
- | + | ||
- | < | + | |
- | sudo pip3 install buildozer | + | |
- | </ | + | |
- | === Ressources === | + | |
- | + | ||
- | * https:// | + | |
- | * http:// | + | |
- | + | ||
- | === Cristax === | + | |
- | + | ||
- | Télécharger CrystaX https:// | + | |
- | + | ||
- | == Extraire == | + | |
- | + | ||
- | 700 MO à télécharger, | + | |
- | + | ||
- | ====== Compilation d'un projet | + | |
+ | ==== Init ==== | ||
Ouvrir un terminal dans votre projet: | Ouvrir un terminal dans votre projet: | ||
- | + | | |
- | ==== Init ==== | + | |
- | + | ||
- | '' | + | |
==== Edition de buildozer.spec ==== | ==== Edition de buildozer.spec ==== | ||
- | |||
**Points importants** | **Points importants** | ||
- | |||
<code python> | <code python> | ||
# (str) Source code where the main.py live | # (str) Source code where the main.py live | ||
Ligne 83: | Ligne 41: | ||
# (list) Application requirements | # (list) Application requirements | ||
# comma seperated e.g. requirements = sqlite3, | # comma seperated e.g. requirements = sqlite3, | ||
- | requirements = python3crystax==3.5, kivy | + | requirements = python3,kivy,openssl |
- | + | ||
- | # (str) Presplash of the application | + | |
- | presplash.filename = %(source.dir)s/ | + | |
- | + | ||
- | # (str) Icon of the application | + | |
- | icon.filename = %(source.dir)s/ | + | |
- | + | ||
- | # (str) Supported orientation (one of landscape, portrait or all) | + | |
- | orientation = landscape | + | |
# (list) Permissions | # (list) Permissions | ||
android.permissions = INTERNET, | android.permissions = INTERNET, | ||
- | # (str) Android | + | # SDK 20 / API 26 / NDK 15c / Python 3.7 |
- | android.ndk = 10.3.2 | + | android.api = 26 |
- | + | android.sdk = 20 | |
- | # (str) Android NDK directory (if empty, it will be automatically downloaded.) | + | android.ndk = 15c |
- | android.ndk_path = /home/toto/crystax-ndk-10.3.2 | + | android.sdk_path = / |
+ | android.ndk_path = /media/data/src_android/ | ||
# (str) The Android arch to build for, choices: armeabi-v7a, | # (str) The Android arch to build for, choices: armeabi-v7a, | ||
android.arch = armeabi-v7a | android.arch = armeabi-v7a | ||
</ | </ | ||
+ | |||
==== Version ==== | ==== Version ==== | ||
- | |||
Il faut définir une version pour l' | Il faut définir une version pour l' | ||
=== Version Méthode 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. | 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) | # (str) Application versioning (method 1) | ||
Ligne 125: | Ligne 72: | ||
</ | </ | ||
=== Version Méthode 2 === | === Version Méthode 2 === | ||
- | |||
La version est définie dans ce fichier buildozer.spec: | La version est définie dans ce fichier buildozer.spec: | ||
- | |||
< | < | ||
# (str) Application versioning (method 1) | # (str) Application versioning (method 1) | ||
Ligne 136: | Ligne 81: | ||
version = 1.2.0 | version = 1.2.0 | ||
</ | </ | ||
- | === Attention === | ||
- | Et en plus android n'est pas intelligent artificiel: | ||
- | Pour Android, version = 1.0 est inférieur à version = 0.506, et il dit: | + | ==== Compilation du apk ==== |
- | + | buildozer -v android debug | |
- | ça semble pourri ton truc, je l' | + | |
- | + | ||
- | ==== Exemple ==== | + | |
- | + | ||
- | * https:// | + | |
- | + | ||
- | ===== Compilation du apk ===== | + | |
- | + | ||
- | '' | + | |
- | + | ||
- | ===== .buildozer ===== | + | |
- | + | ||
- | La compilation va créer un dossier .buildozer d'une taille en gros de 1 Go !! | + | |
- | + | ||
- | ====== Quand ça plante ====== | + | |
- | + | ||
- | = | + | |
+ | ===== Quand ça plante ===== | ||
* buildozer android clean | * buildozer android clean | ||
- | * Détruire /home/pierre/ | + | * Détruire /home/user/ |
* .buildozer du home | * .buildozer du home | ||
* .buildozer de votre dossier | * .buildozer de votre dossier | ||
* .android du home | * .android du home | ||
- | ====== Debug de l' | + | ===== Debug de l' |
- | Si l' | ||
- | |||
- | ==== Kivy Launcher ==== | ||
- | |||
- | Cette méthode n' | ||
- | |||
- | * https:// | ||
==== Suivre tout ce qui se passe sur le téléphone avec logcat ==== | ==== Suivre tout ce qui se passe sur le téléphone avec logcat ==== | ||
- | + | | |
- | | + | < |
- | + | sudo apt-get install adb | |
- | '' | + | adb root |
- | '' | + | adb shell |
- | '' | + | kminilte:/ |
- | '' | + | |
- | + | ||
- | ====== Limitation de kivy ====== | + | |
- | + | ||
- | buildozer pour python3 est en développement | + | |
- | + | ||
- | * Aucun accent dans les fichier *.kv | + | |
- | * Les packages utilisés dans kivy doivent être dans Crystax. | + | |
- | * Le *.apk de [[https:// | + | |
- | + | ||
- | ==== UTF-8 dans .kv ==== | + | |
- | + | ||
- | === 1 === | + | |
- | + | ||
- | Cette proposition ne marche pas dans android après compilation buildozer! | + | |
- | + | ||
- | <code python> | + | |
- | with open(filename, | + | |
- | Builder.load_string(f.read()) | + | |
</ | </ | ||
- | Marchent seulement avec kivy, en exécution directe. | ||
- | === 2 === | ||
- | |||
- | '' | ||
- | |||
- | en début de kv ne marche pas | ||
- | |||
- | Par contre, il est possible de définir mettre une variable dans le main, pour définir le str du kv | ||
- | |||
- | Dans truc.kv: | ||
- | |||
- | <code python> | ||
- | Label: | ||
- | id: Titre | ||
- | font_size: | ||
- | text: self.titre.text | ||
- | </ | ||
- | Dans main.py: | ||
- | |||
- | <code python> | ||
- | class Machin(Screen): | ||
- | titre = ObjectProperty() | ||
- | |||
- | # Dans le __init__() ou ailleurs | ||
- | self.titre.text = " | ||
- | </ | ||
- | ====== Les packages python 3.5 impossibles ====== | ||
- | * twisted qui n'est pas officiellement porté en python 3 en novembre 2017 et n'est pas pris en charge par buildozer | ||
- | ====== Un jeu en cours de développement qui marche ====== | ||
- | * [[Kivy_Multi_Pong|Kivy Multi Pong]] | ||
- | {{tag>kivy}} | + | {{tag>archive sb}} |
archives/kivy_buildozer_pour_creer_une_application_android_avec_un_script_python.txt · Dernière modification : 2019/12/26 09:38 de serge