Pillow not work on android app

432 views
Skip to first unread message

1000 MMO

unread,
Aug 26, 2021, 4:44:26 AM8/26/21
to Kivy users support
Hello friends !
I use pillow library to process screenshots from my phone screen. Specifically, I imported the library as follows:
from PIL import Image, ImageFilter
import PIL.ImageOps

Building the apk file and starting the app works perfectly. But when starting to use PIL Image, ImageFilter, the app stops suddenly.
I declared the full pillow as follows:
requirements = python3,kivy==2.0.0,Pillow
----
When I use pydroid3 and run my main.py file it works fine. I think there's something wrong with the pillow library. Or the declaration is not enough for kivy to recognize the Image extension, ImageFilter.Hope to get help. Thank so much

Wilson Mutebi

unread,
Aug 26, 2021, 7:52:01 AM8/26/21
to kivy-...@googlegroups.com
Try 'pillow' with lowercase and not 'Pillow'

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e5d46678-0b88-4dfc-9950-9e59a68f39d8n%40googlegroups.com.

Lurious Silveirous

unread,
Aug 26, 2021, 8:01:43 AM8/26/21
to kivy-...@googlegroups.com
Try to use PIL on the requeriments

1000 MMO

unread,
Aug 26, 2021, 9:35:31 AM8/26/21
to Kivy users support
I try Pillow, pillow, Pillow==7.0.0 
all of them didn't solve my problem

Vào lúc 18:52:01 UTC+7 ngày Thứ Năm, 26 tháng 8, 2021, wilsonm...@gmail.com đã viết:

1000 MMO

unread,
Aug 26, 2021, 10:07:40 AM8/26/21
to Kivy users support
I try PIL but not work. I think the system failed to find the extension in the library. Do you have any other ideas?
requirements = python3,kivy==2.0.0,numpy,PIL

is it related to garden_requirements?



Vào lúc 19:01:43 UTC+7 ngày Thứ Năm, 26 tháng 8, 2021, luwey...@gmail.com đã viết:

Matthew Proudman

unread,
Aug 26, 2021, 11:11:24 AM8/26/21
to kivy-...@googlegroups.com
Hi all 

this might be because PIL uses external dependcy that can not packaged into .APK file

Wilson Mutebi

unread,
Aug 26, 2021, 11:46:16 AM8/26/21
to kivy-...@googlegroups.com
Mathew could be right though I have done quite a number of projects with pillow as an active requirement. Could you share with us your log at after the app is running on the phone? 

1000 MMO

unread,
Aug 26, 2021, 12:17:49 PM8/26/21
to Kivy users support
I have attached the files. Do you have any ideas to fix this problem?

Vào lúc 22:46:16 UTC+7 ngày Thứ Năm, 26 tháng 8, 2021, wilsonm...@gmail.com đã viết:
main.py
Logcat.txt
buildozer.spec

Wilson Mutebi

unread,
Aug 26, 2021, 12:36:32 PM8/26/21
to kivy-...@googlegroups.com
Have tried to use the "buildozer android debug deploy run" command when building the app? It will show you what causes the problem. Just set your logcat level in the spec file to 2. Then connect your device after enabling developer mode with USB debugging. The run that above command and look at the logs as the app is running until it crashes 

Robert

unread,
Aug 26, 2021, 1:15:29 PM8/26/21
to Kivy users support
Look in the logcat for "Traceback"
Just like on the desktop, look at the end of the traceback:

08-26 17:26:40.464 27096 27165 I python : File "/content/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/oro/PIL/Image.py", line 2809, in open
08-26 17:26:40.466 27096 27165 I python : PermissionError: [Errno 13] Permission denied: '/sdcard/Pictures/screen1629973598207471oro.png'

It is a permission issue.

Wilson Mutebi

unread,
Aug 26, 2021, 1:18:19 PM8/26/21
to kivy-...@googlegroups.com
Oh it a read or write permission. 

Robert

unread,
Aug 26, 2021, 1:26:52 PM8/26/21
to Kivy users support
Yes, but if you use Android>=10 the resolution requires the MediaStore, not simply read permission.

In that case the easiest thing to do is (assuming you supplied the image) is to put the imgae in local storage not in shared storage.

Wilson Mutebi

unread,
Aug 26, 2021, 1:28:46 PM8/26/21
to kivy-...@googlegroups.com

1000 MMO

unread,
Aug 26, 2021, 1:50:38 PM8/26/21
to Kivy users support
I am using for samsung s7 390N, android 8, root magisk. 
I would like to thank Robert and wilsonm   for the logcat issue. I have no experience in reading logcat, it's too informative. I will reconsider about permissions.
I will solve the problem based on the above analysis and report back to you when it is done. Best regards


Vào lúc 00:28:46 UTC+7 ngày Thứ Sáu, 27 tháng 8, 2021, wilsonm...@gmail.com đã viết:

Robert

unread,
Aug 26, 2021, 4:02:15 PM8/26/21
to Kivy users support
You can filter the logcat to just messages from Python, which most issues are.

Using Buildozer:

# (str) Android logcat filters to use
android.logcat_filters = *:S python:D

Using adb:

adb logcat *:S python:D

1000 MMO

unread,
Aug 27, 2021, 6:07:49 AM8/27/21
to Kivy users support

Hello Guys !
I have solved this problem. I neglected to give sdcard management permission when installing the app. So I just need to grant the app permission in the app settings.
Thanks for the support from Robert and wilsonm. I have learned many things from this problem. Best regards !
Vào lúc 03:02:15 UTC+7 ngày Thứ Sáu, 27 tháng 8, 2021, Robert đã viết:
Reply all
Reply to author
Forward
0 new messages