kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.32k stars 1.84k forks source link

Service notification launch intent causes app crash #1099

Open freshollie opened 7 years ago

freshollie commented 7 years ago

My application runs a foreground service which creates a notification for the service.

If the user clicks the notification they get "Stopped working" dialog, but the app does launch.

Build spec: https://github.com/freshollie/cashpassport-tracker/blob/master/buildozer.spec

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

Kivy Activity: https://github.com/freshollie/cashpassport-tracker/blob/master/src/main.py

    def start_tracker_service(self):
        self.log("Starting android service")
        from jnius import autoclass

        trackerService = autoclass('com.freshollie.cashpassporttracker.ServiceTransactiontrackerservice')
        mActivity = autoclass('org.kivy.android.PythonActivity').mActivity

        argument = ''
        trackerService.start(mActivity, argument)

Service: https://github.com/freshollie/cashpassport-tracker/blob/master/src/service.py

I/ActivityManager(  889): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity (has extras)} from uid 10037 on display 0
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): addAppToken: AppWindowToken{2efade7f token=Token{2b77039e ActivityRecord{23ec1dd9 u0 com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity t410}}} to stack=1 task=410 at 1
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/PythonActivity( 5081): My oncreate running
V/PythonActivity( 5081): About to do super onCreate
V/SDL     ( 5081): Device: falcon_umts
V/SDL     ( 5081): Model: XT1032
V/SDL     ( 5081): onCreate():org.kivy.android.PythonActivity@716c0c7
V/PythonActivity( 5081): Did super onCreate
V/SDL     ( 5081): getting identifier
V/SDL     ( 5081): kind is drawable and name presplash
V/SDL     ( 5081): result is 2130837506
V/SDL     ( 5081): asked to get string presplash_color
V/SDL     ( 5081): getting identifier
V/SDL     ( 5081): kind is string and name presplash_color
V/SDL     ( 5081): result is 2130968578
V/PythonActivity( 5081): Ready to unpack
V/PythonActivity( 5081): UNPACKING!!! private app
V/SDL     ( 5081): asked to get string private_version
V/SDL     ( 5081): getting identifier
V/SDL     ( 5081): kind is string and name private_version
V/SDL     ( 5081): result is 2130968577
V/PythonActivity( 5081): Data version is 1503746957.75
V/SDL     ( 5081): onResume()
V/WindowManager(  889): Adding window Window{3dcbbbaa u0 com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity} at 7 of 12 (after Window{34c6a2ae u0 com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity})
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/PythonUtil( 5081): Loaded everything!
V/PythonActivity( 5081): Setting env vars for start.c and Python to use
V/PythonActivity( 5081): Access to our meta-data...
I/PythonActivity( 5081): Surface will NOT be transparent
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): Adding window Window{10e45338 u0 SurfaceView} at 7 of 13 (before Window{3dcbbbaa u0 com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity})
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/SDL     ( 5081): surfaceCreated()
V/SDL     ( 5081): surfaceChanged()
V/SDL     ( 5081): pixel format RGB_565
V/SDL     ( 5081): Window size:720x1131
D/Sensors (  889): AccelerationSensor: set delay 20
I/SDL     ( 5081): SDL_Android_Init()
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
I/SDL     ( 5081): SDL_Android_Init() finished!
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
I/python  ( 5081): Initialize Python for Android
I/python  ( 5081): Changing directory to the one provided by ANDROID_ARGUMENT
I/python  ( 5081): /data/data/com.freshollie.cashpassporttracker/files/app
I/python  ( 5081): Preparing to initialize python
I/python  ( 5081): crystax_python does not exist
F/libc    ( 5081): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 5437 (SDLThread)
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/SDL     ( 5081): onWindowFocusChanged(): true
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
I/LaunchCheckinHandler(  889): Displayed com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity,wp,ca,131
I/ActivityManager(  889): Displayed com.freshollie.cashpassporttracker/org.kivy.android.PythonActivity: +131ms
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
V/WindowManager(  889): IKSWL-6868 finishPostLayoutPolicyLw: mHideKeyguard=false mDismissKeyguard=0
V/WindowManager(  889): IKSWL-6868 setKeyguardOccludedLw isOccluded=false wasOccluded=false showing=false
I/DEBUG   (  335): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  335): Build fingerprint: 'motorola/falcon_tescogbsl/falcon_umts:5.1/LPBS23.13-56-2/2:user/release-keys'
I/DEBUG   (  335): Revision: 'p3c0'
I/DEBUG   (  335): ABI: 'arm'
I/DEBUG   (  335): pid: 5081, tid: 5437, name: SDLThread  >>> com.freshollie.cashpassporttracker <<<
I/DEBUG   (  335): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
I/DEBUG   (  335):     r0 a5bc2108  r1 a5bc2108  r2 fffffc7c  r3 00000000
I/DEBUG   (  335):     r4 00000001  r5 a4702af8  r6 a36bd3a0  r7 00000001
I/DEBUG   (  335):     r8 00000001  r9 a4702af8  sl 00000001  fp a68ca080
I/DEBUG   (  335):     ip 80000000  sp a46fe920  lr a5b276f9  pc a5b271dc  cpsr 600b0030
I/DEBUG   (  335): 
I/DEBUG   (  335): backtrace:
I/DEBUG   (  335):     #00 pc 000c61dc  /data/app/com.freshollie.cashpassporttracker-2/lib/arm/libpython2.7.so (PySys_GetObject+11)
I/DEBUG   (  335):     #01 pc 000c66f5  /data/app/com.freshollie.cashpassporttracker-2/lib/arm/libpython2.7.so (PySys_SetArgvEx+84)
freshollie commented 6 years ago

An update to this. It seems to be fixed by the @mobile-insight team https://github.com/mobile-insight/python-for-android/commit/a4e1d289f28c2e700117fe4f2a31101094c284f8

Though they don't appear to have made a pull request.