-1

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()
Foton
  • 97
  • 1
  • 9

1 Answers1

1

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

MST
  • 651
  • 1
  • 4
  • 6
  • Thanks for your answer, did you unhash the import statement , also what version of python are you using – Foton Nov 12 '21 at 03:58
  • Yes of course, same as kivy imports: "from kivy.app import App from kivy.uix.widget import Widget from kivy.graphics import Color, Ellipse, Line import aiofiles" But in fact your code is not using anything from imported aiofiles, but yes, it was unhashed. I'm using Python 3.8.10. Build process done under Ubuntu 20.04.2 LTS running under WSL (Windows Subsystem for Linux). – MST Dec 28 '21 at 00:06
  • Thanks MST, I switched my python version to 3.8 and specified it in buildozer doesn't crash now must be an issue with 3.6 – Foton Dec 29 '21 at 03:32
  • Because Buildozer currently supports packaging for Android via the python-for-android project (https://github.com/kivy/buildozer) I checked minimum Python for python-for-android and it is currently 3.7.1 (https://python-for-android.readthedocs.io/en/latest/buildoptions/). This is probably reason why 3.6 is not enougth. It's fine for Kivy, but not to build apk using Buildozer. – MST Dec 29 '21 at 13:59