using ctypes with "new" version of p4a "ImportError: No module named _ctypes"

141 views
Skip to first unread message

Paddy Ganut

unread,
Aug 26, 2016, 3:17:14 PM8/26/16
to Kivy users support
previously (18 months ago) I could get applications using the pi3d module to compile and run on android following the various hacks outlined here
http://pi3d.github.io/html/AndroidUse.html
but, supposedly, these modifications have been included in python for android. I have returned to the project now that, hopefully, the p4a revisions have settled down. However when I build using

$ p4a apk --private /home/patrick/raspberry_pi/pi3d_demos/android/ --package=org.example.myapp --name "myapp" --version 0.2 --bootstrap=pygame --requirements=python2,kivy,pi3d --sdk_dir /home/patrick/Android/Sdk/ --ndk_dir /home/patrick/Downloads/android-ndk-r12b --android_api 19 --ndk_ver r12b --meta-data surface.depth=16

and recipe for pi3d

from pythonforandroid.toolchain import PythonRecipe
class Pi3dRecipe(PythonRecipe):
    name = 'pi3d'
    url = 'https://pypi.python.org/packages/e9/dd/25e942027895ba496acbad2b37432a40bac3a177acafed498ff1e171c6b3/pi3d-{version}.tar.gz'
    version = '2.13'
    depends = ['python2', 'kivy', 'pygame', 'numpy', 'pil']

recipe = Pi3dRecipe()

I get the error in logcat

I/python  ( 1470): Initialize Python for Android
I/python  ( 1470): ['/data/data/org.example.myapp/files/lib/python2.7/site-packages', '/data/data/org.example.myapp/files/lib/site-python']
I/python  ( 1470): Android path ['/data/data/org.example.myapp/files/lib/python27.zip', '/data/data/org.example.myapp/files/lib/python2.7', '/data/data/org.example.myapp/files/lib/python2.7/lib-dynload', '/data/data/org.example.myapp/files/lib/python2.7/site-packages', '/data/data/org.example.myapp/files', '/data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL']
I/python  ( 1470): Android kivy bootstrap done. __name__ is __main__
I/python  ( 1470): Run user program, change dir and execute main.py
I/python  ( 1470): Traceback (most recent call last):
I/python  ( 1470):   File "/home/patrick/raspberry_pi/pi3d_demos/android/main.py", line 16, in <module>
I/python  ( 1470):   File "/home/patrick/.local/share/python-for-android/dists/unnamed_dist_1/private/lib/python2.7/site-packages/pi3d/__init__.py", line 10, in <module>
I/python  ( 1470):   File "/home/patrick/.local/share/python-for-android/dists/unnamed_dist_1/private/lib/python2.7/site-packages/pi3d/constants/__init__.py", line 168, in <module>
I/python  ( 1470):   File "/home/patrick/.local/share/python-for-android/dists/unnamed_dist_1/private/lib/python2.7/site-packages/pi3d/constants/__init__.py", line 166, in _detect_platform_and_load_libraries
I/python  ( 1470):   File "/home/patrick/.local/share/python-for-android/dists/unnamed_dist_1/private/lib/python2.7/site-packages/pi3d/constants/__init__.py", line 73, in _linux
I/python  ( 1470):   File "/home/patrick/.local/share/python-for-android/build/other_builds/python2/armeabi/python2/python-install/lib/python2.7/ctypes/__init__.py", line 10, in <module>
I/python  ( 1470): ImportError: No module named _ctypes
I/python  ( 1470): Python for android ended.
I/AndroidRuntime( 1470): VM exiting with result code 0, cleanup skipped.

 
has anybody got the "new" version of p4a working with ctypes? If so, have any tips?

Paddy Ganut

unread,
Aug 27, 2016, 6:21:42 AM8/27/16
to Kivy users support
Update. After searching through the output from p4a apk... I found the culprit: I had modified the malloc.h as in the previous hacks mentioned above - this is now taken care of so isn't needed. However I now get an error as numpy tries to load - ImportError: No module named future_builtins
I've checked the distribution creation output and it definitely seems to compile furture_builtins.so without issue, so a different kind of error.
I notice there is a bootstraps/..../PythonUtil.java that loads _io.so unicodedata.so and _ctypes.so so maybe future_builtins.so needs to go in there?

Alexander Taylor

unread,
Aug 27, 2016, 9:54:06 AM8/27/16
to Kivy users support
You shouldn't need to do anything special for this to work. Could you paste the full logcat output from where it fails?

Alexander Taylor

unread,
Aug 27, 2016, 9:56:07 AM8/27/16
to Kivy users support
Actually, are you using the pygame bootstrap? It looks like
future_builtins.so is blacklisted there, you need to whitelist it or
(probably better) use the sdl2 bootstrap for it to work.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/XchfXbc0KpU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


signature.asc

Paddy Ganut

unread,
Aug 27, 2016, 6:36:24 PM8/27/16
to Kivy users support
Alexander, thanks for info. Yes I had traced the error to pygame bootstrap blacklist and commented out the relevant line (sounds like the whitelist system is what I should have done) However I now get a pretty horrible seg fault type error see below (a section from the middle, I can post the whole thing somewhere if it's useful). I did initially try sdl2 as that's recommended as the default long term bootstrap, however on my phone (running kitkat) I got an error message

SDL Error: Couldn't load python3.5m: findLibrary returned null

and, as the pygame system worked previously, I thought I would switch back to that. I will give it a go using sdl2 again but with the unaltered ndk ... malloc.h and let you know what I get.

Here's the current logcat error section
D/dalvikvm( 5098): Trying to load lib /data/app-lib/org.example.myapp-1/libsqlite3.so 0xb1d448b0
D
/dalvikvm( 5098): Added shared lib /data/app-lib/org.example.myapp-1/libsqlite3.so 0xb1d448b0
D
/dalvikvm( 5098): No JNI_OnLoad found in /data/app-lib/org.example.myapp-1/libsqlite3.so 0xb1d448b0, skipping init
D
/dalvikvm( 5098): Trying to load lib /data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_sqlite3.so 0xb1d448b0
E
/dalvikvm( 5098): dlopen("/data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_sqlite3.so") failed: dlopen failed: library "/data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_sqlite3.so" not found
D
/dalvikvm( 5098): Trying to load lib /data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_imaging.so 0xb1d448b0
E
/dalvikvm( 5098): dlopen("/data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_imaging.so") failed: dlopen failed: library "/data/data/org.example.myapp/files/lib/python2.7/lib-dynload/_imaging.so" not found
I
/python  ( 5098): Starting audio thread
I
/libSDL  ( 5098): Physical screen resolution is 1196x720
D
/dalvikvm( 5098): GC_CONCURRENT freed 1470K, 41% free 3458K/5780K, paused 10ms+13ms, total 188ms
I
/python  ( 5098): Initialize Python for Android
I
/python  ( 5098): ['/data/data/org.example.myapp/files/lib/python2.7/site-packages', '/data/data/org.example.myapp/files/lib/site-python']
I
/python  ( 5098): Android path ['/data/data/org.example.myapp/files/lib/python27.zip', '/data/data/org.example.myapp/files/lib/python2.7', '/data/data/org.example.myapp/files/lib/python2.7/lib-dynload', '/data/data/org.example.myapp/files/lib/python2.7/site-packages', '/data/data/org.example.myapp/files', '/data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL']
I
/python  ( 5098): Android kivy bootstrap done. __name__ is __main__
I
/python  ( 5098): Run user program, change dir and execute main.py
D
/dalvikvm( 3508): GC_CONCURRENT freed 456K, 16% free 3426K/4036K, paused 74ms+3ms, total 245ms
I
/python  ( 5098): [WARNING] [Config      ] Older configuration version detected (0 instead of 16)
I
/python  ( 5098): 2016-08-27 18:16:02,212 WARNING: kivy: [Config      ] Older configuration version detected (0 instead of 16)
I
/python  ( 5098): [WARNING] [Config      ] Upgrading configuration in progress.
I
/python  ( 5098): 2016-08-27 18:16:02,225 WARNING: kivy: [Config      ] Upgrading configuration in progress.
I
/python  ( 5098): [INFO   ] [Logger      ] Record log in /data/data/org.example.myapp/files/.kivy/logs/kivy_16-08-27_0.txt
I
/python  ( 5098): 2016-08-27 18:16:02,297 INFO: kivy: [Logger      ] Record log in /data/data/org.example.myapp/files/.kivy/logs/kivy_16-08-27_0.txt
I
/python  ( 5098): [INFO   ] [Kivy        ] v1.9.2-dev0
I
/python  ( 5098): 2016-08-27 18:16:02,289 INFO: kivy: [Kivy        ] v1.9.2-dev0
I
/python  ( 5098): [INFO   ] [Python      ] v2.7.2 (default, Aug 27 2016, 20:07:49)
I
/python  ( 5098): [GCC 4.9.x 20150123 (prerelease)]
I
/python  ( 5098): 2016-08-27 18:16:02,331 INFO: kivy: [Python      ] v2.7.2 (default, Aug 27 2016, 20:07:49)
I
/python  ( 5098): [GCC 4.9.x 20150123 (prerelease)]
I
/python  ( 5098): [INFO   ] [Factory     ] 193 symbols loaded
I
/python  ( 5098): 2016-08-27 18:16:02,482 INFO: kivy: [Factory     ] 193 symbols loaded
I
/python  ( 5098):  /data/data/org.example.myapp/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:12: RuntimeWarning: import cdrom: No module named cdrom
I
/python  ( 5098): 2016-08-27 18:16:07,203 WARNING: kivy: stderr: /data/data/org.example.myapp/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:12: RuntimeWarning: import cdrom: No module named cdrom
I
/python  ( 5098):  (ImportError: No module named cdrom)
I
/python  ( 5098): 2016-08-27 18:16:07,213 WARNING: kivy: stderr: (ImportError: No module named cdrom)
I
/python  ( 5098): [INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
I
/python  ( 5098): 2016-08-27 18:16:07,333 INFO: kivy: [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
F
/libc    ( 5098): invalid address or address of corrupt block 0xb8726b78 passed to dlfree
F
/libc    ( 5098): Fatal signal 11 (SIGSEGV), thread 5112 (Thread-139)
I
/DEBUG   (   50): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I
/DEBUG   (   50): Build fingerprint: 'generic/google_sdk/generic:4.4.2/KK/3079183:eng/test-keys'
I
/DEBUG   (   50): Revision: '0'
I
/DEBUG   (   50): pid: 5098, tid: 5112, name: Thread-139  >>> org.example.myapp:python <<<
I
/DEBUG   (   50): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
I
/DEBUG   (   50): Abort message: 'invalid address or address of corrupt block 0xb8726b78 passed to dlfree'
I
/DEBUG   (   50):     r0 00000000  r1 b6f0f1ae  r2 deadbaad  r3 b6f12d66
I
/DEBUG   (   50):     r4 b8726b78  r5 b6f1d158  r6 a697a000  r7 b8726b80
I
/DEBUG   (   50):     r8 b8626420  r9 a8b16bc0  sl 00000001  fp 00000000
I
/DEBUG   (   50):     ip 00000001  sp a79dde38  lr b6ee1593  pc b6ee1594  cpsr 68000030
I
/DEBUG   (   50):     d0  3fcc7288e957b53b  d1  4008000000000000
I
/DEBUG   (   50):     d2  7e37e43c8800759c  d3  7e37e43c8800759c
I
/DEBUG   (   50):     d4  0000000000000000  d5  3fbc71c71c71c71c
I
/DEBUG   (   50):     d6  3ff0000000000000  d7  3fc999999999999a
I
/DEBUG   (   50):     d8  0000000000000000  d9  0000000000000000
I
/DEBUG   (   50):     d10 0000000000000000  d11 0000000000000000
I
/DEBUG   (   50):     d12 0000000000000000  d13 0000000000000000
I
/DEBUG   (   50):     d14 0000000000000000  d15 0000000000000000
I
/DEBUG   (   50):     scr 20000010
I
/DEBUG   (   50):
I
/DEBUG   (   50): backtrace:
I
/DEBUG   (   50):     #00  pc 00011594  /system/lib/libc.so (dlfree+1191)
I
/DEBUG   (   50):     #01  pc 0000dafb  /system/lib/libc.so (free+10)
I
/DEBUG   (   50):     #02  pc 00047ffd  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_free_small+4)
I
/DEBUG   (   50):     #03  pc 000471b5  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):     #04  pc 0004723f  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):     #05  pc 00039719  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_destroy+12)
I
/DEBUG   (   50):     #06  pc 0003c34b  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_destroy_decompress+2)
I
/DEBUG   (   50):     #07  pc 00027fe0  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (ImagingJpegDecode+448)
I
/DEBUG   (   50):
I
/DEBUG   (   50): stack:
I
/DEBUG   (   50):          a79dddf8  a8b16bc0  /data/app-lib/org.example.myapp-1/libpython2.7.so
I
/DEBUG   (   50):          a79dddfc  00000001  
I
/DEBUG   (   50):          a79dde00  a79dde70  [stack:5112]
I
/DEBUG   (   50):          a79dde04  e2d32274  
I
/DEBUG   (   50):          a79dde08  b8726b78  [heap]
I
/DEBUG   (   50):          a79dde0c  b6f1d158  
I
/DEBUG   (   50):          a79dde10  a697a000  
I
/DEBUG   (   50):          a79dde14  b6ee2909  /system/lib/libc.so
I
/DEBUG   (   50):          a79dde18  b6f0f1ae  /system/lib/libc.so
I
/DEBUG   (   50):          a79dde1c  a79dde2c  [stack:5112]
I
/DEBUG   (   50):          a79dde20  b6f12d66  /system/lib/libc.so
I
/DEBUG   (   50):          a79dde24  b6ee1593  /system/lib/libc.so (dlfree+1190)
I
/DEBUG   (   50):          a79dde28  b6f0f1ae  /system/lib/libc.so
I
/DEBUG   (   50):          a79dde2c  b8726b78  [heap]
I
/DEBUG   (   50):          a79dde30  df002777  
I
/DEBUG   (   50):          a79dde34  e3a070ad  
I
/DEBUG   (   50):     #00  a79dde38  b6f19000  /system/lib/libc.so
I
/DEBUG   (   50):          a79dde3c  0000070c  
I
/DEBUG   (   50):          a79dde40  b8626420  [heap]
I
/DEBUG   (   50):          a79dde44  b8717e68  [heap]
I
/DEBUG   (   50):          a79dde48  b871d6d8  [heap]
I
/DEBUG   (   50):          a79dde4c  b6eddafd  /system/lib/libc.so (free+12)
I
/DEBUG   (   50):     #01  a79dde50  00000700  
I
/DEBUG   (   50):          a79dde54  a7ff2001  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_free_small+8)
I
/DEBUG   (   50):     #02  a79dde58  00000700  
I
/DEBUG   (   50):          a79dde5c  a7ff11b9  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):
I
/DEBUG   (   50): memory near r1:
I
/DEBUG   (   50):     b6f0f18c 69747075 64206e6f 63657465 20646574  
I
/DEBUG   (   50):     b6f0f19c 25207962 696c0073 6d5f6362 6f6c6c61  
I
/DEBUG   (   50):     b6f0f1ac 6e690063 696c6176 64612064 73657264  
I
/DEBUG   (   50):     b6f0f1bc 726f2073 64646120 73736572 20666f20  
I
/DEBUG   (   50):     b6f0f1cc 72726f63 20747075 636f6c62 7025206b  
I
/DEBUG   (   50):     b6f0f1dc 73617020 20646573 25206f74 616d0073  
I
/DEBUG   (   50):     b6f0f1ec 79732078 6d657473 74796220 3d207365  



Paddy Ganut

unread,
Aug 27, 2016, 6:40:36 PM8/27/16
to Kivy users support
OK so that attempt to post the logcat listing didn't work. I will try again, attaching the whole file.
logcat001.txt

Alexander Taylor

unread,
Aug 27, 2016, 6:44:09 PM8/27/16
to kivy-...@googlegroups.com
Try with python2, python3 is more experimental and has some important
differences. If you already had python2 in your requirements, never
mind, this speaks to a different error.
> (5098):2016-08-2718:16:07,203WARNING:kivy:stderr:/data/data/org.example.myapp/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:12:RuntimeWarning:importcdrom:Nomodulenamed
> cdrom
> I/python (5098): (ImportError:Nomodulenamed cdrom)
> I/python
> (5098):2016-08-2718:16:07,213WARNING:kivy:stderr:(ImportError:Nomodulenamed
> cdrom)
> I/python (5098):[INFO ][Image
> ]Providers:img_tex,img_dds,img_gif,img_pygame,img_pil (img_ffpyplayer
> ignored)
> I/python (5098):2016-08-2718:16:07,333INFO:kivy:[Image
> ]Providers:img_tex,img_dds,img_gif,img_pygame,img_pil (img_ffpyplayer
> ignored)
> F/libc (5098):invalid address oraddress of corrupt block
> 0xb8726b78passed to dlfree
> F/libc (5098):Fatalsignal 11(SIGSEGV),thread 5112(Thread-139)
> I/DEBUG ( 50):************************************************
> I/DEBUG (
> 50):Buildfingerprint:'generic/google_sdk/generic:4.4.2/KK/3079183:eng/test-keys'
> I/DEBUG ( 50):Revision:'0'
> I/DEBUG (
> 50):pid:5098,tid:5112,name:Thread-139 >>>org.example.myapp:python <<<
> I/DEBUG ( 50):signal 11(SIGSEGV),code 1(SEGV_MAPERR),fault addr deadbaad
> I/DEBUG ( 50):Abortmessage:'invalid address or address of corrupt
signature.asc

Paddy Ganut

unread,
Aug 27, 2016, 7:11:12 PM8/27/16
to Kivy users support
Should be just py2, this is the line from the build output

[INFO]:    Recipe build order is ['hostpython2', 'jpeg', 'png', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'python2', 'numpy', 'pil', 'sdl2', 'six', u'pi3d', 'pyjnius', u'kivy']


However the error on the emulator is pretty similar. Various mentions of PIL _imaging.so but not sure that's the culprit. Not tried it on my phone yet to see if I still get the python3.5m sdl error

E/libEGL  ( 5255): eglQuerySurface:590 error 300d (EGL_BAD_SURFACE)
E
/libEGL  ( 5255): eglQuerySurface:590 error 300d (EGL_BAD_SURFACE)
E
/EGL_emulation( 5255): tid 5269: eglMakeCurrent(980): error 0x3009 (EGL_BAD_MATCH)
E
/libEGL  ( 5255): eglMakeCurrent:775 error 3009 (EGL_BAD_MATCH)
F
/libc    ( 5255): invalid address or address of corrupt block 0xb88b25f8 passed to dlfree
F
/libc    ( 5255): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 5269 (SDLThread)

I
/DEBUG   (   50): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

I
/DEBUG   (   50): Build fingerprint: 'generic/google_sdk/generic:4.4.2/KK/3079183:eng/test-keys'

I
/DEBUG   (   50): Revision: '0'

I
/DEBUG   (   50): pid: 5255, tid: 5269, name: SDLThread  >>> org.example.myapp <<<
I
/DEBUG   (   50): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
I
/DEBUG   (   50): Abort message: 'invalid address or address of corrupt block 0xb88b25f8 passed to dlfree'

I
/DEBUG   (   50):     r0 00000000
 r1 b6f0f1ae  r2 deadbaad  r3 b6f12d66
I
/DEBUG   (   50):     r4 b88b25f8  r5 b6f1d158  r6 a6617000  r7 b88b2600
I
/DEBUG   (   50):     r8 b87aedd8  r9 a8ae2bc0  sl 00000001  fp 00000000
I
/DEBUG   (   50):     ip 00000001  sp a83d2ce8  lr b6ee1593  pc b6ee1594  cpsr 68000030
I
/DEBUG   (   50):     d0  421041306f800000  d1  4024000000000000
I
/DEBUG   (   50):     d2  4014000000000000  d3  3fe0000000000000
I
/DEBUG   (   50):     d4  0000000000000005  d5  4059000000000000
I
/DEBUG   (   50):     d6  3ff0000000000000  d7  3fe0000000000000

I
/DEBUG   (   50):     d8  0000000000000000  d9  0000000000000000
I
/DEBUG   (   50):     d10 0000000000000000  d11 0000000000000000
I
/DEBUG   (   50):     d12 0000000000000000  d13 0000000000000000
I
/DEBUG   (   50):     d14 0000000000000000  d15 0000000000000000
I
/DEBUG   (   50):     scr 20000010
I
/DEBUG   (   50):
I
/DEBUG   (   50): backtrace:
I
/DEBUG   (   50):     #00  pc 00011594  /system/lib/libc.so (dlfree+1191)
I
/DEBUG   (   50):     #01  pc 0000dafb  /system/lib/libc.so (free+10)
I
/DEBUG   (   50):     #02  pc 00047ffd  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_free_small+4)
I
/DEBUG   (   50):     #03  pc 000471b5  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):     #04  pc 0004723f  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):     #05  pc 00039719  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_destroy+12)
I
/DEBUG   (   50):     #06  pc 0003c34b  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_destroy_decompress+2)
I
/DEBUG   (   50):     #07  pc 00027fe0  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (ImagingJpegDecode+448)
I
/DEBUG   (   50):
I
/DEBUG   (   50): stack:

I
/DEBUG   (   50):          a83d2ca8  a8ae2bc0  /data/app-lib/org.example.myapp-1/libpython2.7.so
I
/DEBUG   (   50):          a83d2cac  00000001  
I
/DEBUG   (   50):          a83d2cb0  a83d2d20  [stack:5269]
I
/DEBUG   (   50):          a83d2cb4  e2d32274  
I
/DEBUG   (   50):          a83d2cb8  b88b25f8  [heap]
I
/DEBUG   (   50):          a83d2cbc  b6f1d158  
I
/DEBUG   (   50):          a83d2cc0  a6617000  [anon:libc_malloc]
I
/DEBUG   (   50):          a83d2cc4  b6ee2909  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2cc8  b6f0f1ae  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2ccc  a83d2cdc  [stack:5269]
I
/DEBUG   (   50):          a83d2cd0  b6f12d66  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2cd4  b6ee1593  /system/lib/libc.so (dlfree+1190)
I
/DEBUG   (   50):          a83d2cd8  b6f0f1ae  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2cdc  b88b25f8  [heap]
I
/DEBUG   (   50):          a83d2ce0  b6f12d66  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2ce4  b88b2df0  [heap]
I
/DEBUG   (   50):     #00  a83d2ce8  b6f19000  /system/lib/libc.so
I
/DEBUG   (   50):          a83d2cec  0000070c  
I
/DEBUG   (   50):          a83d2cf0  b87aedd8  [heap]
I
/DEBUG   (   50):          a83d2cf4  b88b1d78  [heap]
I
/DEBUG   (   50):          a83d2cf8  b887f398  [heap]
I
/DEBUG   (   50):          a83d2cfc  b6eddafd  /system/lib/libc.so (free+12)
I
/DEBUG   (   50):     #01  a83d2d00  00000700  
I
/DEBUG   (   50):          a83d2d04  a7716001  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so (jpeg_free_small+8)
I
/DEBUG   (   50):     #02  a83d2d08  00000700  
I
/DEBUG   (   50):          a83d2d0c  a77151b9  /data/data/org.example.myapp/files/lib/python2.7/site-packages/PIL/_imaging.so
I
/DEBUG   (   50):
I
/DEBUG   (   50): memory near r1:

Paddy Ganut

unread,
Aug 27, 2016, 7:24:41 PM8/27/16
to Kivy users support
Yes, when I run this on my phone I still get the python3.5m error. I have seen this raised as an issue on the github site. I don't remember seeing a solution, unfortunately!

It's hard to tell where the error is being generated from the logcat trace. pi3d does try to pick up the EGL surface from kivy (formerly as provided by pygame) but when we were getting it working 18 months ago there was usually a python backtrace relating to the bit of pi3d code causing the issue. This error looks to be caused by the loading of the p4a machinery.

Alexander Taylor

unread,
Aug 27, 2016, 7:31:29 PM8/27/16
to kivy-...@googlegroups.com
I think the python3.5m thing just arises from some misleading code in
the bootstrap, so don't worry about that.

Have you built an apk without pi3d at all, to check that the build
process works on your machine?

Also, do you/pi3d actually need PIL to work?
signature.asc

Paddy Ganut

unread,
Aug 28, 2016, 4:13:35 AM8/28/16
to Kivy users support
Good idea to eliminate issues one by one as you suggest. pi3d uses PIL to read image files from disk (which is fairly core in 3D graphics) and for text. If those processes are avoided then it should run without PIL being installed. I won't do any more testing for a day or two but I will post results when I do.

Paddy Ganut

unread,
Aug 29, 2016, 7:35:36 PM8/29/16
to Kivy users support
Some additional info: If I remove the PIL requirement and any reference to it from pi3d then the app loads and starts to run but with sdl2 bootstrap it fails trying to pick up an EGL drawing surface using eglGetCurrentSurface(EGL_DRAW). If I switch back to pygame then it runs... on the emulator. On my phone it crashes, but can't see the error message. So it's hopeful news. But the fact is that version from early 2015 worked with PIL and I've had an apk on Google play since then with quite a few downloads and no complaints of it not working

Paddy Ganut

unread,
Aug 30, 2016, 5:08:38 PM8/30/16
to Kivy users support
Noticed a warning that libtoolize wasn't installed so added that but made no difference. I remembered that I had used target sdk 14 before so tried that but seems to be the same error (will see if this makes any difference with running on my phone).

I don't know if this is relevant but the error in logcat seems to relate to _imaging.c in PIL, and there is a warning

[DEBUG]:       _imaging.c: In function '_putdata':
[DEBUG]:       _imaging.c:1322:17: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[DEBUG]:                        image->image32[y][x] = *((INT32*) ink);
[DEBUG]:                        ^
[DEBUG]:       _imaging.c: In function '_filter':
[DEBUG]:       _imaging.c:842:8: warning: 'kernelsize' may be used uninitialized in this function [-Wmaybe-uninitialized]
[DEBUG]:            if (kernelsize != xsize * ysize) {
[DEBUG]:               ^


when I look at the Pillow code on github for _imaging.c _putdata and _filter both these have been patched

union {
     
char ink[4];
     INT32 inkint
;
} u;
u
.inkint = 0;

op
= PySequence_Fast_GET_ITEM(seq, i);
if (!op || !getink(op, image, u.ink)) {
     
Py_DECREF(seq);
     
return NULL;
 
}

image
->image32[y][x] = u.inkint;

and

if (kernelsize != (Py_ssize_t) xsize * (Py_ssize_t) ysize) {

However the original PIL code worked when I used p4a last year so the change in behaviour must be because of some change in the way that the code is being integrated. Did there used to be something in the old-style recipe that needs to be added to the new one?

Paddy Ganut

unread,
Aug 30, 2016, 6:16:55 PM8/30/16
to Kivy users support
Further update - the non-PIL version works on my phone as well as the emulator. However this isn't completely satisfactory as I have to convert images to compressed numpy npz files and further tweak various classes to behave differently if PIL can't be imported.

Presumably this change (improvement) is due to switching to compiling the apk for android 14 rather than 19 which somehow seems a bit precarious. Anyway, goodish news.
Reply all
Reply to author
Forward
0 new messages