[TIMOB-24159] Android: Null pointer exception in destroyRunners() of Android.Service
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-11-23T20:19:03.000+0000 |
Affected Version/s | Release 6.0.0 |
Fix Version/s | Release 6.1.0 |
Components | Android |
Labels | android, community, notable, nullpointer, service |
Reporter | Michael Gangolf |
Assignee | Gary Mathews |
Created | 2016-11-20T13:59:08.000+0000 |
Updated | 2016-11-23T20:19:19.000+0000 |
Description
When working with Android background services this error appears:
11-16 09:15:04.549: W/TiJSIntervalService(17859): (main) [15,652959] Thrown while clearing interval service runners: Attempt to invoke interface method 'void java.util.List.clear()' on a null object reference
11-16 09:15:04.549: W/TiJSIntervalService(17859): java.lang.NullPointerException: Attempt to invoke interface method 'void java.util.List.clear()' on a null object reference
11-16 09:15:04.549: W/TiJSIntervalService(17859): at ti.modules.titanium.android.TiJSIntervalService.destroyRunners(TiJSIntervalService.java:114)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at ti.modules.titanium.android.TiJSIntervalService.onDestroy(TiJSIntervalService.java:125)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.app.ActivityThread.handleStopService(ActivityThread.java:4009)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.app.ActivityThread.access$2400(ActivityThread.java:210)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1807)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.os.Handler.dispatchMessage(Handler.java:102)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.os.Looper.loop(Looper.java:145)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at android.app.ActivityThread.main(ActivityThread.java:6938)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at java.lang.reflect.Method.invoke(Native Method)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at java.lang.reflect.Method.invoke(Method.java:372)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
11-16 09:15:04.549: W/TiJSIntervalService(17859): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
because the clear() method is called outside the null-check:
https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/modules/android/src/java/ti/modules/titanium/android/TiJSIntervalService.java#L113
Example and PR will follow
app.js
myservice.js
tiapp.xml addition:
PR: https://github.com/appcelerator/titanium_mobile/pull/8634
Good catch! Assigning to [~gmathews] to review for 6.1.0. Thx!
Verified fixed, was no longer able to see the error caused by Android background services (error shown in the description) on SDK version 6.1.0.v20161123033537. *Environement*