简体   繁体   中英

App crashed in buildozer android debug - no module named 'kivy._event"

I built a KivyMD app, working in pycharm. When I compiled for android in buildozer in linux, it launched then crashed. This is the log stating no module named kivy._event. I noticed that there is an _event.pxd in the kivy/uix folder which was referenced by the screenmanager. Hope someone can help. Many thanks.

08-26 20:53:09.196  3942  4337 I python  : Initializing Python for Android
08-26 20:53:09.196  3942  4337 I python  : Setting additional env vars from p4a_env_vars.txt
08-26 20:53:09.196  3942  4337 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
08-26 20:53:09.196  3942  4337 I python  : /data/user/0/org.xxxxxxxxx.appname/files/app
08-26 20:53:09.196  3942  4337 I python  : Preparing to initialize python
08-26 20:53:09.196  3942  4337 I python  : _python_bundle dir exists
08-26 20:53:09.196  3942  4337 I python  : calculated paths to be...
08-26 20:53:09.197  3942  4337 I python  : /data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/stdlib.zip:/data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/modules
08-26 20:53:09.197  3942  4337 I python  : set wchar paths...
08-26 20:53:09.227  3942  4337 I python  : Initialized python
08-26 20:53:09.227  3942  4337 I python  : AND: Init threads
08-26 20:53:09.227  3942  4337 I python  : testing python print redirection
08-26 20:53:09.228  3942  4337 I python  : Android path ['.', '/data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/stdlib.zip', '/data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/modules', '/data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/site-packages']
08-26 20:53:09.228  3942  4337 I python  : os.environ is environ({'PATH': '/sbin:/system/sbin:/product/bin:/apex/com.android.runtime/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'ANDROID_RUNTIME_ROOT': '/apex/com.android.runtime', 'ANDROID_TZDATA_ROOT': '/apex/com.android.tzdata', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/featurelayer-widget.jar:/system/framework/hwEmui.jar:/system/framework/hwPartBasicplatform.jar:/system/framework/telephony-separated.jar:/system/framework/hwTelephony-common.jar:/system/framework/hwPartTelephony.jar:/system/framework/hwPartTelephonyVSim.jar:/system/framework/hwPartTelephonyCust.jar:/system/framework/hwPartTelephonyFullnetworkOpt.jar:/system/framework/hwPartTelephonyTimezoneOpt.jar:/system/framework/hwPartTelephonyOpt.jar:/system/framework/hwPartSecurity.jar:/system/framework/hwPartSecurityFaceId.jar:/system/framework/hwIms-common.jar:/system/framework/hwPartMedia.jar:/system/framework/hwPartConnectivity.jar:/system/framework/hwPartPowerOffice.jar:/system/framework/hwPartDeviceVirtualization.jar:/system/framework/hwPartAirSharing.jar:/system/framework/hwPartDefaultDFR.jar:/system/framework/hwPartDFR.jar:/system/framework/hwPartMagicWindow.jar:/system/framework/hwPartIaware.jar:/system/framework/hwPartMdm.jar:/system/framework/hwPartVr.jar:/system/framework/hwframework.jar:/system/framework/com.huawei.nfc.jar:/system/framework/org.ifaa.android.manager.jar:/system/framework/hwperf.jar:/system/framework/hwcustEmui.jar:/system/framework/hwcustframework.jar:/system/framework/servicehost.jar:/system/framework/hwcustIms-common.jar:/system/framework/hwcustTelephony-common.jar:/system/framework/hwIAwareAL.jar:/system/framework/zframework.z.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar', 'DEX2OATBOOTCLASSPATH': '/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/featurelayer-widget.jar:/system/framework/hwEmui.jar:/system/framework/hwPartBasicplatform.jar:/system/framework/telephony-separated.jar:/system/framework/hwTelephony-common.jar:/system/framework/hwPartTelephony.jar:/system/framework/hwPartTelephonyVSim.jar:/system/framework/hwPartTelephonyCust.jar:/system/framework/hwPartTelephonyFullnetworkOpt.jar:/system/framework/hwPartTelephonyTimezoneOpt.jar:/system/framework/hwPartTelephonyOpt.jar:/system/framework/hwPartSecurity.jar:/system/framework/hwPartSecurityFaceId.jar:/system/framework/hwIms-common.jar:/system/framework/hwPartMedia.jar:/system/framework/hwPartConnectivity.jar:/system/framework/hwPartPowerOffice.jar:/system/framework/hwPartDeviceVirtualization.jar:/system/framework/hwPartAirSharing.jar:/system/framework/hwPartDefaultDFR.jar:/system/framework/hwPartDFR.jar:/system/framework/hwPartMagicWindow.jar:/system/framework/hwPartIaware.jar:/system/framework/hwPartMdm.jar:/system/framework/hwPartVr.jar:/system/framework/hwframework.jar:/system/framework/com.huawei.nfc.jar:/system/framework/org.ifaa.android.manager.jar:/system/framework/hwperf.jar:/system/framework/hwcustEmui.jar:/
08-26 20:53:09.228  3942  4337 I python  : Android kivy bootstrap done. __name__ is __main__
08-26 20:53:09.228  3942  4337 I python  : AND: Ran string
08-26 20:53:09.228  3942  4337 I python  : Run user program, change dir and execute entrypoint
08-26 20:53:09.298  3942  4337 I python  : [WARNING] [Config      ] Older configuration version detected (0 instead of 21)
08-26 20:53:09.298  3942  4337 I python  : [WARNING] [Config      ] Upgrading configuration in progress.
08-26 20:53:09.304  3942  4337 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/org.xxxxxxxxx.appname/files/app/.kivy/logs/kivy_22-08-26_0.txt
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Kivy        ] v2.0.0
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/org.xxxxxxxxx.appname/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Python      ] v3.9.9 (main, Aug 25 2022, 20:26:03) 
08-26 20:53:09.305  3942  4337 I python  : [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Python      ] Interpreter at ""
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Logger      ] Purge log fired. Analysing...
08-26 20:53:09.305  3942  4337 I python  : [INFO   ] [Logger      ] Purge finished!
08-26 20:53:09.306  3942  4337 I python  :  Traceback (most recent call last):
08-26 20:53:09.306  3942  4337 I python  :    File "/home/xxxxxxxxx/Appname/.buildozer/android/app/main.py", line 1, in <module>
08-26 20:53:09.306  3942  4337 I python  :    File "/home/xxxxxxxxx/Appname/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Appname/armeabi-v7a/kivy/uix/screenmanager.py", line 195, in <module>
08-26 20:53:09.306  3942  4337 I python  :    File "/home/xxxxxxxxx/Appname/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/Appname/armeabi-v7a/kivy/event.py", line 8, in <module>
08-26 20:53:09.307  3942  4337 I python  :  ModuleNotFoundError: No module named 'kivy._event'
08-26 20:53:09.307  3942  4337 I python  : Python for android ended.

buildozer.spec

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy==2.1.0,kivymd,sdl2_ttf==2.0.15,pillow,requests,gtts,urllib3,chardet,idna,ffpyplayer
# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1
# (int) Target Android API, should be as high as possible.
android.api = 31
# (int) Minimum API your APK will support.
#android.minapi = 21

# (int) Android SDK version to use
#android.sdk = 20

# (str) Android NDK version to use
#android.ndk = 19b
android.ndk = 23b

_event.pxd file in uix

# This is a "jumping" module, required for python-for-android project
# Because we are putting all the module into the same .so, there can be name
# conflict. We have one conflict with pygame.event and kivy.event => Both are
# python extension and have the same "initevent" symbol. So right now, just
# rename this one.
__all__ = ('EventDispatcher', 'ObjectWithUid', 'Observable')

import kivy._event
__doc__ = kivy._event.__doc__
EventDispatcher = kivy._event.EventDispatcher
ObjectWithUid = kivy._event.ObjectWithUid
Observable = kivy._event.Observable

I researched and tried a few things. Finally I was able to overcome this. Most posts said the build had some problem. I recommend you remove the.buildozer folder in App folder in Ubuntu. Reinstall kivy, cython and all dependencies.

https://buildozer.readthedocs.io/en/stable/installation.html

Secondly, in the buildozer.spec file requirements. I specified the kivymd master link in Github. You can try these two.

requirements = kivy==2.1.0, kivymd==1.0.2, sdl2_ttf == 2.0.15, pillow

or

requirements = kivy==2.1.0, https://github.com/kivymd/KivyMD/archive/master.zip, sdl2_ttf == 2.0.15, pillow

If you still have modulenotfounderror, I suggest you find the py file inside the kivy or kivymd folder, copy the code to another new py file with different name in the same folder as your main.py, import the class to your main.py. I suspect there are bugs during the build that some py files are not added properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM