Buildozer and Android not working for simplest of apps using KivyMD - compiling on Linux, PIL not found

475 views
Skip to first unread message

Matthew Macdonald-Wallace

unread,
Apr 28, 2022, 7:10:39 AM4/28/22
to Kivy users support
Hi all,

New-ish to Kivy but not to Python, wanted to see how fast I could prototype an Android app without having to learn Flutter etc.

I've followed quite a few tutorials out there on compiling Kivy and KivyMD-based apps to Android using Buildozer, and as you'll be able to see from my code, I'm already using the requirements listed at https://github.com/kivymd/KivyMD/blob/master/README.md#how-to-use-with-buildozer

The code, configuration, and error message can be found at a3ef4bef612b47b3ddbedb6cb23b4d6c

and the command I'm running is as follows:

buildozer -v android deploy run logcat | grep python

The error message is very clear:

 ModuleNotFoundError: No module named 'PIL'

however as I read through the logs I can see that Pillow is installed, so I'm slightly confused as to why this app won't work.

I've repeatedly run buildozer clean and deleted the .buildozer directory as well based on other things I've seen around the various forums, subreddits, and github issues, so I'm now turning to you all for help!

Thanks in advance,

Matt

Matthew Macdonald-Wallace

unread,
Apr 28, 2022, 7:26:45 AM4/28/22
to Kivy users support

Robert

unread,
Apr 28, 2022, 8:26:16 PM4/28/22
to Kivy users support
1) buildozer init
2) add to requirements     KivyMD, pillow

builds and runs

Matthew Macdonald-Wallace

unread,
Apr 29, 2022, 1:54:52 AM4/29/22
to Kivy users support
Thanks,

So I'd tried that multiple times before, but figured "what the hell, let's give it a go again!"

Brand new directory, brand new virtualenv running Python 3.9.7, typed the following commands (the "vim" commands are me adding the two dependencies and doing a cut&paste of the main.py from my gist):

 2010  pip install cython buildozer kivy kivymd pillow
 2011  buildozer init
 2012  vim buildozer.spec
 2013  vim main.py
 2014  vim buildozer.spec
 2015  buildozer -v android deploy run logcat | grep python 

Different error this time:

[INFO]:    Stripping libraries in private dir
[INFO]:    Frying eggs in /home/mmw/Projects/kdmtest/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/main/_python_bundle__arm64-v8a/_python_bundle/site-packages
[INFO]:    <- directory context /home/mmw/Projects/kdmtest/.buildozer/android/platform/python-for-android
[INFO]:    Copying in SDL2 .java files from: /home/mmw/Projects/kdmtest/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/bootstrap_builds/sdl2/jni/SDL/android-project/app/src/main/java/org/libsdl/app
[INFO]:    -> directory context /home/mmw/Projects/kdmtest/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/main
[INFO]:    Saving distribution info
[INFO]:    <- directory context /home/mmw/Projects/kdmtest/.buildozer/android/platform/python-for-android
[INFO]:    # Your distribution was created successfully, exiting.
[INFO]:    Dist can be found at (for now) /home/mmw/Projects/kdmtest/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/main
Error type 3
Error: Activity class {org.test.main/org.kivy.android.PythonActivity} does not exist.

The only thing I've changed in the buildozer.rc from the one provided by "init" are:

1. package.name = main (it was package.name = myapp)
2. requirements = python3,kivy,kivymd,pillow (previously requirements = python3,kivy)

Have I missed a step along the way somewhere? 

Thanks in advance,

Matt

Robert

unread,
Apr 29, 2022, 3:19:24 AM4/29/22
to Kivy users support
That is weird, of course I have no way to know what you didn't do. And I've never seen this before, and can't replicate (I use buildozer 1.3.0) . My log doesn't even have the same [INFO]. I suggest looking further up the log, if you cant find anything post the full log here as a .txt file.

Some obvious stuff to do:

1) Recheck that the install instructions were followed  https://github.com/kivy/buildozer/blob/master/docs/source/installation.rst#android-on-ubuntu-2004-64bit , if you change anything do a 'buildozer appclean' before the build  (and FYI you don't need to locally install kivy kivymd & pillow, but that is not the issue)

2) Reread the quick start.  https://github.com/kivy/buildozer/blob/master/docs/source/quickstart.rst#quickstart 

3) Don't change the package name, not because I know there is an issue, but because it introduces an additional variable in the debug.  After changing back you'll need to do a 'buildozer appclean' before the build.

Matthew Macdonald-Wallace

unread,
Apr 29, 2022, 4:52:30 AM4/29/22
to Kivy users support
re-ran the install deb packages from the readme, it added ncurses.

changed the package name back to myapp but retained it in main.py, ran appclean and rebuilt, and it worked.

Really frustrating, but at least it's running again.

Thanks for your help.

Reply all
Reply to author
Forward
0 new messages