Buildozer generated apk failing with pexpect and multiprocessing

133 views
Skip to first unread message

Bryan Ladd

unread,
Mar 1, 2016, 11:52:04 PM3/1/16
to Kivy users support
When I use buildozer to generate an apk of the following script, the apk will generate and install on an Android device, but crashes when I try to run it. If I comment out importing pexpect and multiprocessing, the apk will run just fine.  I have tried:

1) Copying the libraries to the project drive
2) Copying the libraries to .buildozer/applibs
3) Calling them as application requirements in buildozer.spec (which just the apk build to fail)
4) Even tried adding python as an application requirement in buildozer.spec

I must be missing something simple.  I thought the python libraries were included in buildozer, but even trying to add them does not seem to be working.  Any thoughts?

Also, I know this simple code does not require these functions. I am trying to troubleshoot a larger one that does need these functions.

import os
import time
import multiprocessing as mp #apk runs on device if these 2 are commented out
import pexpect #apk runs on device if these 2 are commented out
import datetime
from sensor_calcs_2650 import *
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout

class st_gui(App):
   
   
def build(self):

        g_master
= BoxLayout(orientation='vertical')
        g_block1
= BoxLayout()
        g_block2
= BoxLayout(orientation='horizontal')
        b1_mainlabel
= Label(text='Device 1')

        b1b1
= Button(text='Connect')
        b1b2
= Button(text='Start')
        b1b3
= Button(text='Pause')
        b1b4
= Button(text='Stop')
       
        g_block1
.add_widget(b1_mainlabel)
        g_block2
.add_widget(b1b1)
        g_block2
.add_widget(b1b2)
        g_block2
.add_widget(b1b3)
        g_block2
.add_widget(b1b4)
       
        g_master
.add_widget(g_block1)
        g_master
.add_widget(g_block2)

       
return g_master

if __name__ == '__main__':
    st_gui
().run()




Oon-Ee Ng

unread,
Mar 2, 2016, 3:39:06 AM3/2/16
to kivy-...@googlegroups.com
I'd try to debug why adding them as requirements fails, since they
seem to install fine here when I add them to my buildozer.spec

I just have
requirements = kivy==master, pexpect, multiprocessing
and that doesn't fail on build.
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Alexander Taylor

unread,
Mar 2, 2016, 5:50:04 AM3/2/16
to Kivy users support
I think we may blacklist multiprocessing, as it doesn't work on Android - that would mean that its files are not included in the APK, in order to save space.

pexpect should probably be packaged properly if you include it in the requirements (it would be installed from pip), but might not work since multiprocessing isn't possible.

I think tito was working on a multiprocessing alternative that would work on android (abstracting the process via using android services instead). Maybe that could be an alternative for you, but I'm not sure.

Bryan Ladd

unread,
Mar 3, 2016, 3:27:34 AM3/3/16
to Kivy users support
It looks to me like virtualenv is calling a version of pip that does not support "--download-cache".  Here were a couple workarounds I considered:

1) Direct vitrualenv to use a different pip version: used the link below, but that did not solve the problem. Actually ended up causing more problems...
http://stackoverflow.com/questions/25806982/pip-version-in-virtualenv

2) Manually providing buildozer with the applibs: looking at the log, it looks like buildozer cleans out that folder, so anything I put in there manually will be deleted when executing. Tried anyway of course...did not work.

Any suggestions as to where to go from here?


# Install requirement pexpect in virtualenv
# Run 'pip install --download-cache=/home/bryan/.buildozer/cache --target=/home/bryan/Desktop/Android/.buildozer/applibs pexpect'
# Cwd /home/bryan/Desktop/Android/.buildozer

Usage:  
  pip install
[options] <requirement specifier> [package-index-options] ...
  pip install
[options] -r <requirements file> [package-index-options] ...
  pip install
[options] [-e] <vcs project url> ...
  pip install
[options] [-e] <local project path> ...
  pip install
[options] <archive url/path> ...

no such option: --download-cache
# Command failed: pip install --download-cache=/home/bryan/.buildozer/cache --target=/home/bryan/Desktop/Android/.buildozer/applibs pexpect
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2




Oon-Ee Ng

unread,
Mar 3, 2016, 4:00:37 AM3/3/16
to kivy-...@googlegroups.com
That's a known issue which is already fixed in master for buildozer
last I checked. The fix is simple enough, you can do it yourself too.
For clarity, the __init__.py I mention there is the one for buildozer.

https://github.com/kivy/buildozer/issues/279
Reply all
Reply to author
Forward
0 new messages