Table of Contents
Why this kivyMD recipe
After the development of the app in Python, Kivyย andย KivyMD, eventually, you would want to convert the python code to an android app. For this step, you need to add kivyMD as a requirements in Python for android or Buildozer. KivyMD has undergone a major change recently. The kivyMD mentioned in pypi site is old and the latest master branch has so many modifications and additions. This leads to lot of error in your kivyMD function calls.
Python for android also does not have a recipe to download the latest master .zip during the conversion of python code to an app.
Following is the recipe for kivymd in python for android
To add this recipe do the following
- Download the zip from the github page and click code and download zip
- extract the zip file
- go to the folder where the files are extracted
- execute the following command
cp -r ~/.local/lib/python<version-number>/site-packages/pythonforandroid/recipes/
change the version number to the version number you like, if you want a different version
This recipe will also apply a patch since the setup.py fails to copy the .kv files in the package. This patch is also provided
This will build the app with kivyMD
We have built a sample android app using this method and all the files and the android app can be downloaded from the links below
Download the sample code and android app built using the kivymd recipe
Building the app using python for android
Run the following command
p4a apk –private [dir location] –package org.techris.kmd –name “Custom name” –version 24.05.10 –bootstrap sdl2 –requirements python3==3.11.2,kivy,kivymd –sdk-dir [SDK installation location] –ndk-dir [ndk installation location] –android-api 34 –ndk-api 24 –arch armeabi-v7a –arch arm64-v8a –arch x86_64 –permission INTERNET –icon [location of your logo] –presplash [location of your logo] –presplash-color “#CA2D2A” –debug
Replace the items within the brackets [] to suit your needs
Our command is
p4a apk –private $dir –package org.techris.kmd –name “KivyMD recipe Tutorial” –version 24.05.10 –bootstrap sdl2 –requirements python3==3.11.2,kivy,kivymd –sdk-dir /home/gk/Android/Sdk –ndk-dir /home/gk/Documents/android-ndk-r25b-linux/android-ndk-r25b –android-api 34 –ndk-api 24 –arch armeabi-v7a –arch arm64-v8a –arch x86_64 –permission INTERNET –icon /home/gk/Documents/logo.png –presplash /home/gk/Documents/logo.png –presplash-color “#CA2D2A” –debug