python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

Issue with Android example

Open AtlasPilotPuppy opened this issue 8 years ago • 30 comments

The example in examples/android/takepicture Has some issues with PIL

  1. The way this recipe ise set up kivy is the only requirement and thus PIL isnt built/ installed
03-18 00:11:22.875: I/python(5530):    File "/home/anant/projects/kivy/examples/android/takepicture/.buildozer/android/app/main.py", line 32, in <module>
  1. If I add pillow as a requirement I get an error saying
03-17 23:46:50.810: I/python(5430):    File "/home/anant/projects/kivy/examples/android/takepicture/.buildozer/android/app/_applibs/PIL/Image.py", line 66, in <module>
03-17 23:46:50.820: I/python(5430):  ImportError: dlopen failed: "/data/data/org.test.takepicture/files/_applibs/PIL/_imaging.so" is 64-bit instead of 32-bit

I know python-for-android has a recipe for PIL using the original PIL but I am unsure how to triger that through buildozer.

AtlasPilotPuppy avatar Mar 18 '16 06:03 AtlasPilotPuppy

@anantasty have you tried adding pil to the application requirements line in the buildozer.spec file? Line 36 if no edits have been made.

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy,pil 

Loran425 avatar Mar 29 '16 23:03 Loran425

Pip fails to install it instead of installing the recipe

On Tue, Mar 29, 2016, 16:56 Drew A. [email protected] wrote:

@anantasty https://github.com/anantasty have you tried adding pil to the application requirements line in the buildozer.spec file? Line 36 if no edits have been made.

(list) Application requirements

comma seperated e.g. requirements = sqlite3,kivy

requirements = kivy,pil

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/kivy/kivy/issues/4095#issuecomment-203162055

AtlasPilotPuppy avatar Mar 30 '16 16:03 AtlasPilotPuppy

Alright, making sure I understand the problem. The app builds properly but when run on the android device it crashes with the second error from your original comment?

If I add pillow as a requirement I get an error saying

03-17 23:46:50.810: I/python(5430):  File "/home/anant/projects/kivy/examples/android/takepicture/.buildozer/android/app/_applibs/PIL/Image.py", line 66, in <module>
03-17 23:46:50.820: I/python(5430):  ImportError: dlopen failed: "/data/data/org.test.takepicture/files/_applibs/PIL/_imaging.so" is 64-bit instead of 32-bit

Loran425 avatar Mar 30 '16 17:03 Loran425

Yes that is absolutely true. It does not look live pil gets installed since the example doesn't have it in buildspec. Adding pillow installs the 64 bit libs since I am on a 64 bit machine. Adding pil in the build spec doesn't build. Since pil isn't on pip any more. For some reason it tries to install pil from pip and not the recipe.

On Wed, Mar 30, 2016, 10:13 Drew A. [email protected] wrote:

Alright, making sure I understand the problem. The app builds properly but when run on the android device it crashes with the second error from your original comment?

If I add pillow as a requirement I get an error saying

03-17 23:46:50.810: I/python(5430): File "/home/anant/projects/kivy/examples/android/takepicture/.buildozer/android/app/_applibs/PIL/Image.py", line 66, in 03-17 23:46:50.820: I/python(5430): ImportError: dlopen failed: "/data/data/org.test.takepicture/files/_applibs/PIL/_imaging.so" is 64-bit instead of 32-bit

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/kivy/kivy/issues/4095#issuecomment-203533853

AtlasPilotPuppy avatar Mar 31 '16 00:03 AtlasPilotPuppy

Starting to run out of ideas on this one. Because for some reason it builds fine with pil as a requirement for me. Could you toss a verbose buildozer log from when you have pil as a requirement into a gist and share the link?

Loran425 avatar Mar 31 '16 18:03 Loran425

Sure I'll do that. Thanks a lot

On Thu, Mar 31, 2016, 12:14 Drew A. [email protected] wrote:

Starting to run out of ideas on this one. Because for some reason it builds fine with pil as a requirement for me. Could you toss a verbose buildozer log from when you have pil as a requirement into a gist and share the link?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/kivy/kivy/issues/4095#issuecomment-204061238

AtlasPilotPuppy avatar Apr 01 '16 20:04 AtlasPilotPuppy

Hey there!

We're automatically closing this issue since the original poster (or another commenter) hasn't yet responded to the question or request made to them 14 days ago. We therefore assume that the user has lost interest or resolved the problem on their own. Closed issues that remain inactive for a long period may get automatically locked.

Don't worry though; if this is in error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

(Please note that this is an automated comment.)

kivybot avatar Dec 25 '16 00:12 kivybot

I would appreciate that you re-open this issue. The way forward was to use pygame instead of PIL to resize images, however this is not satisfactory solution.

alrea333 avatar May 09 '17 17:05 alrea333

Have pil in my spec file, did "from PIL import Image" on my py file, and still get the error: (buildozer 0.33 with Python3)

Traceback (most recent call last): File "/home/suporte/Desktop/Mobile/Vistorias/.buildozer/android/app/main.py", line 84, in File "/home/suporte/Desktop/Mobile/Vistorias/.buildozer/android/platform/build/dists/frvistorias/private/lib/python2.7/site-packages/PIL/Image.py", line 56, in ImportError: dlopen failed: "/data/data/ind.frtech.car.frvistorias/files/app/lib/python2.7/site-packages/PIL/_imaging.so" is 64-bit instead of 32-bit

@inclement that's the reason I need pillow so badly hahaha

dfrison01 avatar Jul 26 '17 21:07 dfrison01

Hey guys.. I have the same issue when try to use opencv in android application.. Here is the error message logged to android adb logcat:

ImportError: dlopen failed: "/data/data/org.test.myapp/files/app/lib/python2.7/site-packages/cv2/cv2.so" is 64-bit instead of 32-bit

If anyone knows how to fix this error please comment below..

VajiraPrabuddhaka avatar Aug 09 '17 11:08 VajiraPrabuddhaka

I have the exact same problem here. And I have to specify that I was correctly working few days ago (I used it for only for generating image file, and it worked as intended).
I have "pillow" in my requirement, logs said it was installed via pip. But now it won't work.

my logcat display:

I/python  (10432):  Traceback (most recent call last):
I/python  (10432):    File "/home/mathias/Stage/DepoGit/Pygmacontroller/V1.2/.buildozer/android/app/main.py", line 29, in <module>
I/python  (10432):    File "/home/mathias/Stage/DepoGit/Pygmacontroller/V1.2/.buildozer/android/app/matrixconfiguration.py", line 20, in <module>
I/python  (10432):    File "/home/mathias/Stage/DepoGit/Pygmacontroller/V1.2/.buildozer/android/platform/build/dists/operatorshift/private/lib/python2.7/site-packages/PIL/Image.py", line 56, in <module>
I/python  (10432):  ImportError: dlopen failed: "/data/data/com.pygmatec.operatorshift/files/app/lib/python2.7/site-packages/PIL/_imaging.so" not 32-bit: 2
I/python  (10432): Python for android ended.

matEhickey avatar Aug 11 '17 16:08 matEhickey

Would be nice to have the issue marked as Open again, since the problem still exists for multiple users and crashes the apps

dfrison01 avatar Aug 14 '17 19:08 dfrison01

You should NOT put pillow in your requirements since it does not (yet) have a recipe, see #786. If you use pillow in your requirements you will get the "not 32-bit" error.

AndreMiras avatar Oct 19 '17 22:10 AndreMiras

Hi @VajiraPrabuddhaka I got the same issue when I tried to put opencv as requirement in the buildozer.spec. Did you manage to fix this on your own ?

ImportError: dlopen failed: "/data/data/org.test.test_apk/files/app/crystax_python/site-packages/cv2/cv2.so" is 64-bit instead of 32-bit

NicoLivesey avatar Feb 15 '18 17:02 NicoLivesey

@NicoLivesey am also running on same issue... you found a fix?

ksaikiranr avatar Apr 28 '18 12:04 ksaikiranr

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have the means to take action. Please reach out if you have or find the answers we need so that we can investigate further.

no-response[bot] avatar Apr 28 '18 13:04 no-response[bot]

That doesn't seem like very good bot behaviour.

inclement avatar Apr 28 '18 13:04 inclement

i have the same problem i can't create any file on the device. Wen i try the app crash

blinhares avatar Jun 18 '18 00:06 blinhares

Bump. Please resolve this

vivek3141 avatar Feb 22 '19 03:02 vivek3141

@anyone is this resolved? w.r.t. original issue with Pillow it gets imported with import PIL but is installed with pip install Pillow. The latter format is what should be dropped into buildspec reqs

But I get same "is 64-bit instead of 32-bit" error with opencv, same as multiple users above.

Am I to understand this error as apk installing 64 bit during build, but Android requiring 32-bit when deployed?

xavier-gutierrez avatar May 07 '19 04:05 xavier-gutierrez

Wait guys the pillow recipe should be working to me https://github.com/kivy/python-for-android/blob/0.7.0/pythonforandroid/recipes/Pillow/init.py I've been using it for https://github.com/kivy-garden/garden.zbarcam and it's working OK. @xavier-gutierrez could you please share your buildozer.spec file. Also to be sure I would use Pillow note the capital P, because I can't remember if p4a is case insensitive, but the recipe definitely has an upper case. Please try again with a clean build, but this definitely works for me also in https://github.com/AndreMiras/QrScan / https://play.google.com/store/apps/details?id=com.github.andremiras.qrscan

AndreMiras avatar May 09 '19 18:05 AndreMiras

Apologies, lost the actual file due to cloning error on my VM -- but I'm 100% sure the requirements line was as follows requirements = python, kivy, Pillow

I've switched to opencv for my image processing task, but I'm getting the same 64-bit error. Now my requirements line is requirements = python3, kivy, opencv-python Does this bypass the kivy recipe and installs PyPi opencv instead?

xavier-gutierrez avatar May 18 '19 15:05 xavier-gutierrez

PS -- since I'm on a VM, maybe specifying a 32-bit machine will compile openCV appropriately for android mobile. I'll let you know how it goes

xavier-gutierrez avatar May 18 '19 15:05 xavier-gutierrez

looks like the p4a recipe already builds for 32 buit, I just had to specify that instead of the PyPi download

requirements = python3, kivy, opencv

xavier-gutierrez avatar May 18 '19 22:05 xavier-gutierrez

Solution: in windows operating system install pillow madule from comand prompt:

python -m pip install pillow

KamalSaeidi avatar Aug 12 '20 16:08 KamalSaeidi

Same here I/python: ImportError: dlopen failed: "/data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/cv2/cv2.so" is 64-bit instead of 32-bit any solution for cv2.so?

AmitNikhade avatar May 31 '21 11:05 AmitNikhade

+1 I/python:ImportError: dlopen failed: "/data/user/0/****/files/app/_python_bundle/site-packages/cv2/cv2.so" is 64-bit instead of 32-bit

LESSSE avatar Sep 16 '21 09:09 LESSSE

Same here but with opencv, if someone has a fix would be nice to know.

ImportError: dlopen failed: "/data/user/0/org.test.tennistrainingsystem/files/app/_python_bundle/site-packages/cv2/cv2.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)

mabrao avatar May 03 '22 13:05 mabrao

Did you find a solution to this @mabrao ?

tambravan avatar Jun 02 '22 20:06 tambravan