5

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!

Oleksandr K
  • 119
  • 1
  • 10

2 Answers2

4

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.

Ankit Sangwan
  • 1,138
  • 1
  • 7
  • 20
  • Hi, I've tried that, but then the apk wouldn't compile, buildozer crashes. – Oleksandr K Feb 21 '21 at 15:37
  • It should work fine. Can you post the error? Did you add `PIL` or `pillow`? You should add `pillow` not `PIL` – Ankit Sangwan Feb 21 '21 at 15:37
  • So, when I add pillow to the buildozer.spec file I get: "raise CommandNotFound(k) sh.CommandNotFound: cmake". I've read that there is no recipe for pillow yet. But the app was compiling and running on android like 3 days ago... – Oleksandr K Feb 21 '21 at 15:41
  • `sudo -H apt install cmake` – Ankit Sangwan Feb 21 '21 at 15:45
  • when running `sudo -H apt install cmake` I get: `Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/apt" (-1)`. So I've installed the cmake with binary file from the official website. But still the same error in buildozer – Oleksandr K Feb 21 '21 at 15:52
  • you shouldn't get this error. Wait are you on mac? – Ankit Sangwan Feb 21 '21 at 15:58
  • Yes) I've installed `cmake` with `homebrew`. And added `pillow` to `buildozer.spec`. The apk compliles, but the app still crashes on launch. Although, this time logcat doesn't show any errors. But since you've helped with the error "No PIL module" I'm gonna accept your answer – Oleksandr K Feb 21 '21 at 16:13
2

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.

SohailAQ
  • 1,002
  • 1
  • 13
  • 25