Exits unexpectedly when app gets terminated on android
See original GitHub issueYour Environment
- Plugin version: 2.3.6
- Platform: Android (haven’t tried on iOS yet)
- OS version: 8.0.0
- Device manufacturer and model: Samsung Galaxy S9+
- Cordova version (
cordova -v
): 8.0.0 - Cordova platform version (
cordova platform ls
):
Installed platforms:
android 7.1.1
ios 4.5.5
Available platforms:
browser ~5.0.1
osx ~4.0.1
windows ~5.0.0
www ^3.12.0
- Plugin configuration options:
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true,
stopOnTerminate: true,
};
- Link to your project: (private company project)
Context
I’m new to mobile development and had a requirement for background geolocation. I copy-pasted the setup as described here:
Expected Behavior
It is working as expected. I’m getting location updates every now and then but with an additional log error:
But still, i ignored this since i’m getting location updates. But having set stopOnTerminate
to true, I was expecting that i can terminate the app gracefully.
Actual Behavior
Upon closing the app, after about 2-3 seconds, I get an alert message saying that my app has stopped.
Possible Fix
Steps to Reproduce
- Open the app
- Wait for a few seconds
- Close the app by swiping it away
Context
I was hoping to have the app terminate without any errors.
Debug logs
2018-10-01 08:42:18.263 4416-4416/? E/audit: type=1400 audit(1538354538.258:1135): avc: denied { read } for pid=16651 comm="ne.fieldmagicv3" name="vmstat" dev="proc" ino=4026532577 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0 SEPF_SM-G965F_8.0.0_0014 audit_filtered
2018-10-01 08:42:18.263 4416-4416/? E/audit: type=1300 audit(1538354538.258:1135): arch=c00000b7 syscall=56 success=no exit=-13 a0=ffffff9c a1=7fd13d0059 a2=80000 a3=0 items=0 ppid=4950 pid=16651 auid=4294967295 uid=10309 gid=10309 euid=10309 suid=10309 fsuid=10309 egid=10309 sgid=10309 fsgid=10309 tty=(none) ses=4294967295 comm="ne.fieldmagicv3" exe="/system/bin/app_process64" subj=u:r:untrusted_app:s0:c512,c768 key=(null)
2018-10-01 08:42:18.263 4416-4416/? E/audit: type=1327 audit(1538354538.258:1135): proctitle="com.crmonline.fieldmagicv3"
2018-10-01 08:42:21.240 16651-16651/com.crmonline.fieldmagicv3 E/ViewRootImpl: sendUserActionEvent() returned.
2018-10-01 08:42:21.573 16651-16651/com.crmonline.fieldmagicv3 E/ViewRootImpl: sendUserActionEvent() returned.
2018-10-01 08:42:22.206 4820-4839/? E/NotificationService: No Channel found for pkg=com.crmonline.fieldmagicv3, channelId=null, id=1, tag=null, opPkg=com.crmonline.fieldmagicv3, callingUid=10309, userId=0, incomingUserId=0, notificationUid=10309, notification=Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 color=0x00000000 number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)
2018-10-01 08:42:22.251 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request d35603 passive interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:22.272 4820-6847/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:22.296 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request d35603 gps interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:22.301 4820-6472/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:22.305 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request d35603 network interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:22.308 4820-5461/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:42.489 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request a3d0ca fused interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.496 4820-5461/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:42.532 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location remove a3d0ca from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.633 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location remove d35603 from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.639 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request 8530f6 passive interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.644 4820-6472/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:42.644 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request 8530f6 gps interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.646 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request 8530f6 network interval=0 from com.crmonline.fieldmagicv3
2018-10-01 08:42:42.652 4820-6472/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:42.654 4820-6472/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:42:44.386 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location remove 8530f6 from com.crmonline.fieldmagicv3
2018-10-01 08:42:44.397 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location request db442d7 network interval=10000 from com.crmonline.fieldmagicv3
2018-10-01 08:42:44.399 4820-6472/? E/PermissionMonitor: Calling app is not pre-installed on system. Ignore its notification. pkgName: com.crmonline.fieldmagicv3, UserId: 0
2018-10-01 08:43:52.108 4820-4839/? E/NotificationService: No Channel found for pkg=com.crmonline.fieldmagicv3, channelId=null, id=-574543954, tag=null, opPkg=com.crmonline.fieldmagicv3, callingUid=10309, userId=0, incomingUserId=0, notificationUid=10309, notification=Notification(channel=null pri=-2 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)
2018-10-01 08:43:53.980 5556-5598/? E/RequestManager_FLP: [LocationManagerService] Location remove db442d7 from com.crmonline.fieldmagicv3
2018-10-01 08:43:55.064 4820-4839/? E/NotificationService: No Channel found for pkg=com.crmonline.fieldmagicv3, channelId=null, id=1, tag=null, opPkg=com.crmonline.fieldmagicv3, callingUid=10309, userId=0, incomingUserId=0, notificationUid=10309, notification=Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 color=0x00000000 number=0 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)
2018-10-01 08:43:55.136 17669-17669/com.crmonline.fieldmagicv3 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.crmonline.fieldmagicv3, PID: 17669
java.lang.RuntimeException: Unable to start service com.marianhello.bgloc.LocationService@8110c0b with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.crmonline.fieldmagicv3/.MainActivity (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Boolean com.marianhello.bgloc.Config.getStopOnTerminate()' on a null object reference
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3694)
at android.app.ActivityThread.-wrap21(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1801)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Boolean com.marianhello.bgloc.Config.getStopOnTerminate()' on a null object reference
at com.marianhello.bgloc.LocationService.onTaskRemoved(LocationService.java:201)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3679)
at android.app.ActivityThread.-wrap21(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1801)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Based on the logs, it was trying to restart background-geolocation but was unable since the app has been terminated already.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >How to Fix Crashing Apps on an iPhone or Android?
Poor memory management is one of the most common reasons for app crashes on mobile devices (tip: learn Android Studio Debug with Bugfender),...
Read more >java - Unfortunately MyApp has stopped. How can I solve this?
Your application quit because an uncaught RuntimeException was thrown. The most common of these is the NullPointerException . How to solve it?
Read more >11 common reasons for mobile app crashing | DECODE
Mobile apps crash for many different reasons. Sometimes, they are the result of inadequate app testing, poor memory management, or even device ...
Read more >Determine if the App is terminated by the User or by iOS
If your app is launched and your last record indicates it was in the foreground state, then somehow it was terminated unexpectedly.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, all I can say is that I don’t expect any breaking changes till the final 3.0 release.
This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn’t be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it’s important. Thank you for your contributions.