Outils pour utilisateurs

Outils du site


kivy_buildozer

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
kivy_2020_hello_world [2019/12/19 10:43] – [Des problèmes ... des problèmes ...] sergekivy_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>kivy_2020|Toutes les pages Kivy 2020}}** +**{{tagpage>kivy|Toutes les pages Kivy}}** 
-**... {{tagpage>kivy|Toutes les pages Kivy}}** +**[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_buildozer|English Version]]** 
-**...**+</WRAP> 
 +<WRAP center round box 40% centeralign> 
 +**[[les_pages_kivy_en_details|Les pages Kivy en détails]]**
 </WRAP> </WRAP>
- 
 <WRAP center round box 60% centeralign> <WRAP center round box 60% centeralign>
-**[[http://translate.google.com/translate?js=n&sl=auto&tl=en&u=https://ressources.labomedia.org/archives/kivy_comment_creer_une_application_android_en_python|Link to Google Translate]]**+**Generic Python packager for Android and iOS**
 </WRAP> </WRAP>
-=====Le programme python kivy=====+=====Ressources===== 
 +  * **[[https://buildozer.readthedocs.io|Welcome to Buildozer’s documentation]]** 
 +  * **[[https://github.com/kivy/buildozer|Buildozer sur Github]]** 
 + 
 + 
 +=====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:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 zlib1g:i386  libssl-dev openssl gcc libpangoxft-1.0-0:i386 adb libtool build-essential libncurses5-dev libncursesw5-dev libtinfo5 lld 
 +   
 +===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'est le buildozer du venv qui est utilisé !**\\ 
 +Dans le dossier du venv existant: 
 +<code bash> 
 +  source mon_env/bin/activate 
 +  python3 -m pip install buildozer setuptools cython 
 +  buildozer init 
 +   
 +  File buildozer.spec created, ready to customize! 
 +   
 +toto@debian:/media/data/3D/projets/player/app$ source mon_env/bin/activate 
 +(mon_env) toto@debian:/media/data/3D/projets/player/app$ python3 -m pip install -r requirements.txt 
 + 
 +(mon_env) toto@debian:/media/data/3D/projets/player/app$ ./mon_env/bin/buildozer -v android debug 
 +</code> 
 + 
 + 
 +=====Le programme python kivy Hello world===== 
 + 
 +  * **[[https://github.com/sergeLabo/hello-world|Les sources sur github]]** avec le fichier buildozer.spec 
 <file python hello_world.py> <file python hello_world.py>
 #! /usr/bin/env python3 #! /usr/bin/env python3
Ligne 31: Ligne 73:
 =====Compilation avec Buildozer===== =====Compilation avec Buildozer=====
 La page plus ancienne **Kivy Comment créer une application android en python** est en [[archives/kivy_comment_creer_une_application_android_en_python|archive]]. La page plus ancienne **Kivy Comment créer une application android en python** est en [[archives/kivy_comment_creer_une_application_android_en_python|archive]].
-====Instalation==== +====Installation==== 
- +Des ressources suffisantes mais peut-être pas necéssaires !
  
 <code text> <code text>
Ligne 39: Ligne 80:
 sudo apt-get update 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:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 zlib1g:i386 openjdk-11-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 +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:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libidn11:i386 zlib1g:i386 openjdk-11-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 libncurses5-dev libncursesw5-dev libtinfo5 
 +  
 sudo pip3 install jinja2 appdirs sh colorama setuptools cython sudo pip3 install jinja2 appdirs sh colorama setuptools cython
 sudo pip3 install pygame kivy buildozer pyjnius sudo pip3 install pygame kivy buildozer pyjnius
 </code> </code>
-=====Des problèmes ... des problèmes ...===== 
-===openjdk 11 vs 8=== 
-Ce problème se retrouve identiquement sur une Xubuntu18.04 ! 
  
-https://github.com/kivy/buildozer/issues/862+=====Utilisation===== 
 +Le fichier principal qui lance kivy doit s'appeler main.py
  
-  sudo apt remove --purge openjdk-*-jdk +Dans le dossier du projet: 
-  sudo apt install openjdk-11-jdk +  buildozer init 
-Désinstallation de 3 paquets **-8-** +crée le fichier buildozer.spec
-  sudo apt install openjdk-11-source +
-Suppression des .buildozer du home et du dossier, recompil ...+
  
 +====buildozer.spec====
 +Il faut définir une version pour l'application que vous compilez.
 +
 +===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,png,jpg,kv,atlas
 +version = 0.14
 +requirements = python3,kivy
 +orientation = portrait
 +fullscreen = 0
 +android.arch = armeabi-v7a
 +
 +[buildozer]
 +log_level = 2
 +warn_on_root = 1
 +</code>
 +
 +=== 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.
 +<code>__version__ = '0.67'</code>
 +<code>
 +# (str) Application versioning (method 1)
 +version.regex = __version__ = ['"](.*)['"]
 +version.filename = %(source.dir)s/main.py
 +
 +# (str) Application versioning (method 2)
 +# version = 1.2.0
 +</code>
 +
 +=== Version Méthode 2 ===
 +La version est définie dans ce fichier buildozer.spec:
 +<code>
 +# (str) Application versioning (method 1)
 +#version.regex = __version__ = ['"](.*)['"]
 +#version.filename = %(source.dir)s/main.py
 +
 +# (str) Application versioning (method 2)
 +version = 1.2.0
 +</code>
 +
 +====Compilation====
 +  buildozer -v android debug
 + 
 +Le *.apk sera dans ./bin
 +
 +=====openjdk 11 vs 8=====
 +====L'erreur dans logcat de adb====
 +  java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
 +
 +<code>
 +# Installing/updating SDK platform tools if necessary
 +# Run '/home/serge/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager tools platform-tools'
 +# Cwd /home/serge/.buildozer/android/platform/android-sdk
 +Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
 +    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
 +    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
 +    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
 +    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
 +    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
 +Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
 +    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
 +    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
 +    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
 +    ... 5 more
 +# Command failed: /home/serge/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager tools platform-tools
 +</code>
 +
 +====Issue 862====
 +Aucunes des solutions proposées par **https://github.com/kivy/buildozer/issues/862** ne marchent.
 +
 +Les recherches avec ce message d'erreur retourne beaucoup de longues pages: il y a un problème avec openjdk 11 ! et pas avec openjdk 8.
 +
 +====Nous utiliserons la version 8: facile !====
 Installation de openjdk8: https://installvirtual.com/install-java-8-on-debian-10-buster/ Installation de openjdk8: https://installvirtual.com/install-java-8-on-debian-10-buster/
   wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -   wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
Ligne 64: Ligne 179:
   sudo update-alternatives --config java   sudo update-alternatives --config java
 Choisir la version 8 ! 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'Allemagne qui gagne===== =====Et à la fin c'est l'Allemagne qui gagne=====
 Victoire ! Une application qui marche ! Victoire ! Une application qui marche !
  
-{{tag>kivy_2020 kivy}}+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:myapp-0.13-armeabi-v7a-debug.apk.zip |}}** 
 + 
 +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://kivy.org/docs/guide/packaging-android.html|Guide Android]] 
 +<code> 
 +sudo apt-get install adb 
 +adb root 
 +adb shell 
 +kminilte:/sdcard/kivy/TapOSC $ logcat 
 +</code> 
 + 
 +{{tag> buildozer kivy python sb }}
kivy_buildozer.1576752198.txt.gz · Dernière modification : 2019/12/19 10:43 de serge