I am fairly new in using kivy
and kivymd
to develop python apps. I have been working on a personal app that will be used to store daily expenses. For that I am a using cloud MySQL Database. The python program works absolutely fine on Windows like the way I intended. For testing purposes and to make sure that kivy can actually work on android, I created a "Hello World" display app with kivy and kivymd in python and converted it into apk file using Buildozer
in GoogleColab
to be tested on my android device. It worked just fine on all my devices running on different android versions. I have created the accounts tracker app, and in the similar way in Google Colab I converted it into apk file. I tested the app on my device and it crashed past the loading screen. But surprisingly it worked just fine on another android device that I have.
Specification of Device 1(App Crashed):
- Model: realme 9 5G Speed Edition,
- Android Version: 13.
Specification of Device 2(App Working):
- Model: Samsung Galaxy M30s,
- Android Version: 11.
The "Hello World" simple app worked absolutely fine in both the devices mentioned above.
I am providing my source code of the accounts app in a Google Drive Link because it's a large file. Although It won't run on other Windows devices until and unless python mysql connector is installed and configured and the default database is feed in to that system.
Link:- https://drive.google.com/drive/folders/1_81YTYqYW6g2cjMW8UUmb9Rs5A6KC1Vm?usp=drive_link
Note:- For security and privacy reasons I have changed the MySQL server connection configuration in my Python file from my hosting server to local host. But my apps are built using connection configured to be used with my hosting server database.
I have used logcat
in Android Studio and connected my mobile to get error/crash logs.
Error Logs from my app:-
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
I have used -s python
command in logcat to filter out python logs. Here are the logs that I got from my app:-
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)
As far as I understood from the error crash logs from backtracing that few libraries are unreadable on my device. But if Google Colab has created an corrupted apk then it should have crashed on every device. But it works on other devices(Not to mention that the layout is broken but thats another troubleshoot for another day)
While doing my resarch about the troubleshoot I got to know that the error might be because of lower targetSDK
. Apparently Buildozer created the apk using api-31. Since my device is running on Android 13 it needed an target sdk of above 33. So,upon doing the necessary changes(using API-34) I created the apk again and it crashed again giving the same error logs on logcat
.
My Buildozer.specs file:-
[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
I have changed the Android api version to 34 and ndk version to 25b
which is latest according to p4a documentation
and Android Documentation
. I have tried both with and without the sdk changes and each time the app crashed after loading screen on my android device but ran perfectly on another android device.
Also I have changed the requirements and declared all the packages that I have used in my build
. I have also uncommented the android permissions
part since I would be needing Internet access to connect to the cloud database. I have tried using both kivy and kivymd master files yet no luck
.
It runs absolutely fine on the Samsung Device but crashes on my realme device
Please help me, its been almost a week I am stuck at this problem trying to figure out. Else I am thinking of just abandoning it and start fresh with flutter. But I really wanted to move with python as I have a good experience and knowledge with python.