kivymd app crashes on android phone ModuleNotFoundError: No module named 'PIL'

Viewed 1812

My Kivy app crashes on launch on android phone. buildozer logcat shows the following error:

02-21 17:09:58.777 14941 14979 I python  :  ModuleNotFoundError: No module named 'PIL'
02-21 17:09:58.777 14941 14979 I python  : Python for android ended.

Here are my buildozer.spec requirements:

requirements = python3,kivy==2.0.0,git+https://github.com/HeaTTheatR/KivyMD.git,sdl2_ttf==2.0.15,python-dateutil,requests,urllib3,chardet,idna,plyer,android,jnius,oscpy

As I understand, only the KivyMD depends on PIL. The app works perfectly on my mac and WAS working before on the android phone. The error just started to occur. So, I'm really confused and would appreciate any help. Thanks in advance!

2 Answers

As you might already know, KivyMD depends on PIL, not Kivy. You are using the latest version of KivyMD using git in your app, which depends on PIL. To remove the error just add pillow in the requirements of your buildozer.spec file.

If you are still not getting the desired result after following the correct answer, do refer to the requirements specidied in buildozer.spec file for the KivyMD-kitchen_sink app in the repo.

This is the link -> Kitchen_Sink_Repo

Tip

If, after changing the requirements you still see your app crashing, run the following command(s)

buildozer android clean
buildozer android debug deploy run

Why?

Because when buildozer installs the earlier specified requirements, it is quiet possible that it installs versions that are not matching your apps specifications. So clean it and then run.

You should now be good to go.

Related