Aiofiles import not working in buildozer, apk building but crashing

309 Views Asked by At

Has anyone had any success incorporating aiofiles into a buildozer apk. The package is building but crashes once the apk is installed on the phone or emulator. I have tested all the other imports and they work fine.Buildozer spec is below

[app]

title = MyApplication

package.name = myapp

package.domain = org.test

source.dir = .

source.include_exts = py,png,jpg,kv,atlas,json,mp3,gif,txt,md,gitignore,ttf,zip,cfg,TTF

#source.include_patterns = assets/,images/.png

#source.exclude_exts = spec

#source.exclude_dirs = tests, bin

#source.exclude_patterns = license,images//.jpg

version = 0.1

requirements = python3,kivy,google,pyjnius,kivymd,certifi,kivyauth,openssl,ws4py,jnius,android,google-auth,credentials,oauth2,urllib3,oauth2client,firebase,pygame,jwcrypto,pycryptodome,sseclient,requests_toolbelt,python_jwt,gcloud,rsa,cryptography,httplib2,pyrebase,sdl2,sdl2_image,sdl2_mixer,sdl2_ttf, firebase-auth,cachetools,google-cloud,firebase-client,google-cloud-storage,jwt,PIL,chardet,nodejs,ast,aiofiles,threading,datetime,os,sys,re,cython,pip,setuptools,threading,concurrent.futures,asyncio,plyer

orientation = portrait

osx.python_version = 3

osx.kivy_version = 1.9.1

fullscreen = 0

#android.permissions = INTERNET

#android.api = 30

#android.minapi = 21

#android.sdk = 20

#android.ndk_api = 21

#android.private_storage = True

#android.ndk_path =

#android.sdk_path =

#android.logcat_filters = *:S python:D

#android.copy_libs = 1

android.arch = armeabi-v7a

p4a.branch = master

#ios.kivy_ios_url = https://github.com/kivy/kivy-ios

ios.ios_deploy_url = https://github.com/phonegap/ios-deploy ios.ios_deploy_branch = 1.7.0

#[buildozer]

#from kivy.app import App
#from kivy.uix.widget import Widget
#from kivy.graphics import Color, Ellipse, Line


#import aiofiles





class MyPaintWidget(Widget):

    def on_touch_down(self, touch):
        with self.canvas:
            Color(1, 1, 0)
            d = 30.
            Ellipse(pos=(touch.x - d / 2, touch.y - d / 2),   size=(d, d))
            touch.ud['line'] = Line(points=(touch.x, touch.y))

    def on_touch_move(self, touch):
        touch.ud['line'].points += [touch.x, touch.y]


class MyPaintApp(App):

    def build(self):
        return MyPaintWidget()


if __name__ == '__main__':
    MyPaintApp().run()
1

There are 1 best solutions below

4
On

To be able to import aiofiles you have to specify it within requirements param of buildozer.spec file. You already specified it there, but you also specified a lot of unused dependencies too. One of problem is that you separated concurrent and futures module with dot instead of comma, which makes it impossible to install by pip.

I removed unused dependencies, leaving it like this:

requirements = python3,kivy,aiofiles

then apk builds with success, and it's running without issues on Android device.

In general, whenever your app crashes on android it's good to see Android console output to figure out what's wrong. Uncomment android.logcat_filters = *:S python:D line within buildozer.spec file, then build & deploy it over ADB using:

buildozer -v android debug deploy run logcat

Look at documentation: https://buildozer.readthedocs.io/en/latest/quickstart.html#init-and-build-for-android