[英]App crashed in buildozer android debug - no module named 'kivy._event"
I built a KivyMD app, working in pycharm.我构建了一个 KivyMD 应用程序,在 pycharm 中工作。 When I compiled for android in buildozer in linux, it launched then crashed.
当我在 linux 的 buildozer 中为 android 编译时,它启动然后崩溃。 This is the log stating no module named kivy._event.
这是说明没有名为 kivy._event 的模块的日志。 I noticed that there is an _event.pxd in the kivy/uix folder which was referenced by the screenmanager.
我注意到屏幕管理器引用的 kivy/uix 文件夹中有一个 _event.pxd。 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 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 _event.pxd 文件在 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.
我建议您删除 Ubuntu 中 App 文件夹中的 .buildozer 文件夹。 Reinstall kivy, cython and all dependencies.
重新安装 kivy、cython 和所有依赖项。
https://buildozer.readthedocs.io/en/stable/installation.html
Secondly, in the buildozer.spec file requirements.其次,在 buildozer.spec 文件中的要求。 I specified the kivymd master link in Github.
我在 Github 中指定了 kivymd 主链接。 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.如果您仍然有modulenotfounderror,我建议您在kivy 或kivymd 文件夹中找到py 文件,将代码复制到与您的main.py 相同的文件夹中另一个不同名称的新py 文件中,将class 导入您的main.py。 I suspect there are bugs during the build that some py files are not added properly.
我怀疑在构建过程中存在一些 py 文件未正确添加的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.