Python Kivy/KivyMD应用程序(.apk)在一个Android设备上显示加载屏幕后崩溃,但在另一个Android设备上运行正常

c90pui9n  于 2023-06-20  发布在  Python
关注(0)|答案(1)|浏览(162)

我在使用**kivykivymd**开发python应用程序方面相当新。我一直在开发一款个人应用程序,将用来存储日常开支。我使用的是MySQL云数据库。Python程序在Windows上运行得非常好,就像我想要的那样。为了测试的目的,并确保kivy实际上可以在android上工作,我用kivy和kivymd在python中创建了一个“Hello World”显示应用程序,并使用GoogleColab中的Buildozer将其转换为apk文件,以便在我的android设备上进行测试。它在我所有运行不同Android版本的设备上都运行得很好。我已经创建了帐户跟踪应用程序,并以类似的方式在谷歌可乐我转换成apk文件。我在我的设备上测试了这个应用程序,它在加载屏幕上崩溃了。但令人惊讶的是,它在我拥有的另一台Android设备上运行得很好。
器械1的质量标准(应用程序崩溃):

  • 型号:realme 9 5G极速版
  • Android版本:13.

设备2的规范(应用程序工作):

  • 型号:Samsung Galaxy M30 s,
  • Android版本:11.
    **简单的“Hello World”应用程序在上述两种设备上都运行得非常好。

我在Google Drive链接中提供了我的帐户应用程序的源代码,因为它是一个大文件。虽然它不会在其他Windows设备上运行,直到和除非python mysql连接器被安装和配置,并且默认数据库被馈送到该系统。
友情链接:-https://drive.google.com/drive/folders/1_81YTYqYW6g2cjMW8UUmb9Rs5A6KC1Vm?usp=drive_link

注意:-出于安全和隐私的原因,我已经将Python文件中的MySQL服务器连接配置从托管服务器更改为本地主机。但我的应用程序是使用配置为与我的托管服务器数据库一起使用的连接构建的。

我在Android Studio中使用了logcat,并连接了我的移动的以获取错误/崩溃日志。
从我的应用程序的错误日志:-

22:05:41.294 32206-32206 p.myaccountsapp                    pid-32206                            E  Invalid ID 0x00000000.
2023-06-19 22:05:41.294 32206-32206 ResourcesImplExt        pid-32206                            E  the AssetManager's apkAsset: ApkAssets{path=<empty> and /system/framework/framework-res.apk}
2023-06-19 22:05:41.294 32206-32206 ResourcesImplExt        pid-32206                            E  the AssetManager's apkAsset: ApkAssets{path=/my_bigball/overlay/GmsConfigOverlayASI_Infrastructure/GmsConfigOverlayASI_Infrastructure.apk}
2023-06-19 22:05:41.294 32206-32206 ResourcesImplExt        pid-32206                            E  the AssetManager's apkAsset: ApkAssets{path=/my_bigball/overlay/GmsConfigOverlayCommonEx/GmsConfigOverlayCommonEx.apk}
2023-06-19 22:05:41.294 32206-32206 ResourcesImplExt        pid-32206                            E  the AssetManager's apkAsset: ApkAssets{path=/my_bigball/overlay/GmsConfigOverlayComms/GmsConfigOverlayComms.apk}
2023-06-19 22:05:41.325 32206-32206 p.myaccountsapp         org.myaccountsapp.myaccountsapp      E  sysOpen failed with error=Permission denied
2023-06-19 22:05:41.473   750-750   SELinux                 hwservicemanager                     E  avc:  denied  { find } for interface=vendor.oplus.hardware.performance::IPerformance sid=u:r:untrusted_app:s0:c246,c257,c512,c768 pid=32206 scontext=u:r:untrusted_app:s0:c246,c257,c512,c768 tcontext=u:object_r:hal_performance_hwservice:s0 tclass=hwservice_manager permissive=0
2023-06-19 22:05:41.488  1892-4210  SensorService           system_server                        E  Required app org.libsdl.app.SDLSurface, uid 10502, pid 32206
2023-06-19 22:05:41.514 32206-32206 SurfaceSyncer           org.myaccountsapp.myaccountsapp      E  Failed to find sync for id=0
2023-06-19 22:05:41.522  8548-8549  IHansComunication       hans                                 E  HANS printMessageBody: RCV message: type = 4,port = 86870,caller_pid = -1,caller_uid = -1,target_pid = -1,target_uid = 10071,pkg_cmd = -1,rpc = PKG/-1
2023-06-19 22:05:41.558 32206-32206 SurfaceSyncer           org.myaccountsapp.myaccountsapp      E  Failed to find sync for id=0
2023-06-19 22:05:42.459 32259-32259 .link:link.data         pid-32259                            E  Unknown bits set in runtime_flags: 0x40000000
2023-06-19 22:05:42.462 32259-32259 .link:link.data         pid-32259                            E  Not starting debugger since process cannot load the jdwp agent.
2023-06-19 22:05:46.733 32206-32251 libc                    org.myaccountsapp.myaccountsapp      A  exiting due to SIG_DFL handler for signal 11, ucontext 0x791f4c4e20
2023-06-19 22:05:46.734 32206-32251 libc                    org.myaccountsapp.myaccountsapp      A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 32251 (SDLThread), pid 32206 (SDLActivity)
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Process name is org.myaccountsapp.myaccountsapp, not key_process
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  keyProcess: 0
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Build fingerprint: 'realme/RMX3461/RE54BFL1:13/TP1A.220905.001/R.105741b-5f5a-5f59:user/release-keys'
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Revision: '0'
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  ABI: 'arm64'
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Timestamp: 2023-06-19 22:05:46.895663675+0530
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Process uptime: 7s
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Cmdline: org.myaccountsapp.myaccountsapp
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  pid: 32206, tid: 32251, name: SDLThread  >>> org.myaccountsapp.myaccountsapp <<<
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  uid: 10502
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  Abort message: 'exiting due to SIG_DFL handler for signal 11, ucontext 0x791f4c4e20'
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A      x0  0000000000000000  x1  0000000000007dfb  x2  0000000000000006  x3  000000791f4c4c60
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A      x4  0000008080808080  x5  0000008080808080  x6  0000008080808080  x7  8080808080000000
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A      x8  00000000000000f0  x9  00000079060eae60  x10 0000000000000001  x11 0000007906150a44
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A  backtrace:
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A    NOTE: Function names and BuildId information is missing for some frames due
                                                                                                      NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
                                                                                                      NOTE: found under the lib/ directory are readable.
                                                                                                      NOTE: On this device, run setenforce 0 to make the libraries readable.
                                                                                                      NOTE: Unreadable libraries:
                                                                                                      NOTE:   /data/data/org.myaccountsapp.myaccountsapp/files/app/_python_bundle/site-packages/kivy/_event.so
                                                                                                      NOTE:   /data/data/org.myaccountsapp.myaccountsapp/files/app/_python_bundle/site-packages/kivy/graphics/compiler.so
                                                                                                      NOTE:   /data/data/org.myaccountsapp.myaccountsapp/files/app/_python_bundle/site-packages/kivy/graphics/instructions.so
                                                                                                      NOTE:   /data/data/org.myaccountsapp.myaccountsapp/files/app/_python_bundle/site-packages/kivy/graphics/vbo.so
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A        #00 pc 000000000007da34  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 59222d1015276d9a9031ee1ea28c0bcd)
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A        #01 pc 00000000000024c8  /apex/com.android.art/lib64/libsigchain.so (art::SignalChain::Handler(int, siginfo*, void*)+1084) (BuildId: c2eed67ad222447f39d6878846f202fc)
2023-06-19 22:05:47.814 32426-32426 DEBUG                   pid-32426                            A        #02 pc 00000000000005d0  [vdso] (__kernel_rt_sigreturn+0)

Same error continues

我在logcat中使用了-s python命令来过滤python日志。以下是我从我的应用程序中获得的日志:

2023-06-19 23:39:20.085 25923-26010 python                  org.myaccountsapp.myaccountsapp      I  os.environ is environ({'PATH': '/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/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_ART_ROOT': '/apex/com.android.art', 'ANDROID_I18N_ROOT': '/apex/com.android.i18n', 'ANDROID_TZDATA_ROOT': '/apex/com.android.tzdata', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'MY_CUSTOM_ROOT': '/my_custom', 'MY_SPECIAL_PRELOAD_ROOT': '/special_preload', 'MY_CARRIER_ROOT': '/my_carrier', 'MY_REGION_ROOT': '/my_region', 'MY_COMPANY_ROOT': '/my_company', 'MY_ENGINEER_ROOT': '/my_engineering', 'MY_ENGINEERING_ROOT': '/my_engineering', 'MY_PRODUCT_ROOT': '/my_product', 'MY_VERSION_ROOT': '/my_version', 'MY_OPERATOR_ROOT': '/my_carrier', 'MY_COUNTRY_ROOT': '/my_region', 'MY_ODM_ROOT': '/odm', 'MY_PRELOAD_ROOT': '/my_preload', 'MY_HEYTAP_ROOT': '/my_heytap', 'MY_STOCK_ROOT': '/my_stock', 'MY_MANIFEST_ROOT': '/my_manifest', 'MY_BIGBALL_ROOT': '/my_bigball', 'DOWNLOAD_CACHE': '/data/cache', 'BOOTCLASSPATH': '/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar:/system/framework/oplus-framework.jar:/system/framework/oplus-support-wrapper.jar:/system/framework/subsystem-framework.jar:/apex/com.android.i18n/javalib/core-icu4j.jar:/apex/com.android.adservices/javalib/framework-adservices.jar:/apex/com.android.adservices/javalib/framework-sdksandbox.jar:/apex/com.android.appsearch/javalib/framework-appsearch.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.ipsec/javalib/android.net.ipsec.ike.jar:/apex/com.android.media/javalib/updatable-media.jar:/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar:/apex/com.android.ondevicepersonalization/javalib/framework-ondevicepersonalization.jar:/apex/com.android.os.statsd/javalib/framework-statsd.jar:/apex/com.android.permission/javalib/framework-permission.jar:/apex/com.android.permission/javalib/framework-permission-s.jar:/apex/com.android.scheduling/javalib/framework-scheduling.jar:/apex/com.android.sdkext/javalib/framework-sdkextensions.jar:/apex/com.android.tethering/javalib/framework-connectivity.jar:/apex/com.android.tethering/javalib/framework-connectivity-t.jar:/apex/com.android.tethering/javalib/framework-tethering.jar:/apex/com.android.uwb/javalib/framework-uwb.jar:/apex/com.android.wifi/javalib/framework-wifi.jar', 'DEX2OATBOOTCLASSPATH': '/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/framework-graphics.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar:/system/framework/oplus-framework.jar:/system/framework/oplus-support-wrapper.jar:/system/framework/subsystem-framework.jar:/apex/com.android.i18n/javalib/core-icu4j.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/com.android.location.provider.jar:/system/framework/services.jar:/system/framework/oplus-services.jar:/system/framework/oplus-servi
2023-06-19 23:39:24.760  1892-2456  WindowManager           system_server                        W  Failed to deliver inset state change to w=Window{e0ec1c4 u0 org.myaccountsapp.myaccountsapp/org.kivy.android.PythonActivity EXITING}
                                                                                                    android.os.DeadObjectException
                                                                                                        at android.os.BinderProxy.transactNative(Native Method)
                                                                                                        at android.os.BinderProxy.transact(BinderProxy.java:672)
                                                                                                        at android.view.IWindow$Stub$Proxy.insetsControlChanged(IWindow.java:473)
                                                                                                        at com.android.server.wm.WindowState.notifyInsetsControlChanged(WindowState.java:4288)

据我从回溯的错误崩溃日志中了解到,在我的设备上很少有库是不可读的。但是,如果Google Colab创建了一个损坏的apk,那么它应该在每台设备上崩溃。但它在其他设备上工作(更不用说布局被破坏了,但那是另一天的另一个故障排除)
在做我的resarch关于故障排除,我知道错误可能是因为较低的targetSDK。显然Buildozer使用API-31创建了apk。由于我的设备运行在Android 13上,因此需要33以上的目标SDK。所以,在做了必要的更改后(使用API-34),我再次创建了apk,它再次崩溃,给出了logcat上相同的错误日志。
我的Buildozer.specs文件:-

[app]

# (str) Title of your application
title = My Accounts App

# (str) Package name
package.name = myaccountsapp

# (str) Package domain (needed for android/ios packaging)
package.domain = org.myaccountsapp

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas

# (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec

# (list) List of directory to exclude (let empty to not exclude anything)
#source.exclude_dirs = tests, bin, venv

# (list) List of exclusions using pattern matching
# Do not prefix with './'
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
version = 0.1

# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = sdl2,hostpython3==3.10.0,python3==3.10.0,kivy==2.2.1,kivymd==1.1.1,pillow,datetime,mysql-connector-python

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (list) Supported orientations
# Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (string) Presplash background color (for android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF

# (string) Presplash animation using Lottie format.
# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/
# for general documentation.
# Lottie files can be created using various tools, like Adobe After Effect or Synfig.
#android.presplash_lottie = "path/to/lottie/file.json"

# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime)
#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png
#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png

# (list) Permissions
# (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)
android.permissions = android.permission.INTERNET, (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)

# (list) features (adds uses-feature -tags to manifest)
#android.features = android.hardware.usb.host

# (int) Target Android API, should be as high as possible.
#android.api = 31
android.api = 34

# (int) Minimum API your APK / AAB will support.
#android.minapi = 21

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

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

# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
#android.ndk_api = 21

我已经根据p4a documentationAndroid Documentation更改了最新的Android api version to 34 and ndk version to 25b。我已经尝试了有和没有sdk的变化,每次应用程序崩溃后,加载屏幕上我的android设备,但运行完美的另一个android设备。
have changed the requirements and declared all the packages that I have used in my build我也有uncommented the android permissions部分,因为我将需要互联网接入连接到云数据库。I have tried using both kivy and kivymd master files yet no luck .它在三星设备上运行得非常好,但在我的realme设备上崩溃了
请帮助我,它已经快一个星期了,我困在这个问题试图弄清楚。否则我想放弃它,重新开始。但是我真的很想用python,因为我对python有很好的经验和知识。

相关问题