Android app crashes on startup - ImportError: No module named mmap

423 views
Skip to first unread message

Darren Dowdall

unread,
Jul 25, 2016, 12:02:43 PM7/25/16
to Kivy users support

Hi, i really hope someone can help me figure this one out, been driving me mad for a while now.
I've built an app that utilizes mutagen (a pure python lib) to retrieve the tags from audio files present on the device. I've bben using buildozer to compile the apk and everything runs to completion without any issues. However, the app now crashes on startup with an import error.

adb logcat provides:

I/python  ( 1670):  Traceback (most recent call last):
I/python  ( 1670):    File "main.py", line 14, in <module>
I/python  ( 1670):      import mutagen
I/python  ( 1670):    File "/data/data/org.nukebox2000.test.nukebox2000/files/lib/python2.7/site-packages/mutagen/__init__.py", line 23, in <module>
I/python  ( 1670):      from mutagen._util import MutagenError
I/python  ( 1670):    File "/data/data/org.nukebox2000.test.nukebox2000/files/lib/python2.7/site-packages/mutagen/_util.py", line 19, in <module>
I/python  ( 1670):      import mmap
I/python  ( 1670):  ImportError: No module named mmap
I/python  ( 1670): Python for android ended.

The mutagen recipe seems to get pulled in during compile but I'm obviously missing something and I've no idea how to approach this (pretty new to Kivy in general).
Any help or pointers would be appreciated.


ps. For the sake of completeness I've attached the .spec file

buildozer.spec

Alexander Taylor

unread,
Jul 25, 2016, 12:20:26 PM7/25/16
to Kivy users support
Looks like mmap is a compiled component, which we remove from the build for space reasons because it isn't normally used. You can include it by adding it to the whitelist, although I'm not certain what the syntax is for this (there's a buildozer option for it though) - maybe specifically whitelist lib-dynload/mmap.so

Darren Dowdall

unread,
Jul 25, 2016, 12:43:24 PM7/25/16
to Kivy users support
Thanks a million Alexander. I'll go and figure this out and post back the solution when I find it.
Cheers again.

Darren Dowdall

unread,
Jul 31, 2016, 4:33:22 PM7/31/16
to Kivy users support
For anyone else who may wish to know, the process was quite simple after.
Build your app (which will fail on trying to import mmap). Then, inside your source directory, open  ".buildozer/android/platform/build/dists/_your_app_dir_/blacklist.txt" and comment out the line under "# unused binaries python modules" which references mmap -> "# lib-dynload/mmap.so" (or whichever module you need).

Darren.

Reply all
Reply to author
Forward
0 new messages