DavidBriglio / cordova-plugin-foreground-service

Foreground service with ongoing notification for Android.
MIT License
39 stars 39 forks source link

Application crashes java.lang.NullPointerException #20

Open mirko77 opened 2 years ago

mirko77 commented 2 years ago

Dear All,

we are getting a lot of crash reports in the Play Console, stack trace:

java.lang.RuntimeException: at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4319) at android.app.ActivityThread.access$2700 (ActivityThread.java:273) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2070) at android.os.Handler.dispatchMessage (Handler.java:112) at android.os.Looper.loop (Looper.java:216) at android.app.ActivityThread.main (ActivityThread.java:7625) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987) Caused by: java.lang.NullPointerException: at com.davidbriglio.foreground.ForegroundService.onStartCommand (ForegroundService.java:16) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4298)

It looks like it happening mostly on Huawei devices

Any suggestion?

Screenshot 2021-09-28 at 10 23 55
LillyWebsites commented 2 years ago

Same problem, in my app always with Android 12 (around 150 times the last days). Only line numbers are slightly different

java.lang.RuntimeException: at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4724) at android.app.ActivityThread.access$2000 (ActivityThread.java:256) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2129) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:201) at android.os.Looper.loop (Looper.java:288) at android.app.ActivityThread.main (ActivityThread.java:7870) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003) Caused by: java.lang.NullPointerException: at com.davidbriglio.foreground.ForegroundService.onStartCommand (ForegroundService.java:16) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4706)

LillyWebsites commented 2 years ago

wait, also have the message for Android 9-11 (over 300 times), but google did another entry for that. also has slightly different rownumbers and access$2100 instead of your access$2700. Got significantly more from 01.05.2022 on

java.lang.RuntimeException: at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4552) at android.app.ActivityThread.access$2100 (ActivityThread.java:274) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2134) at android.os.Handler.dispatchMessage (Handler.java:107) at android.os.Looper.loop (Looper.java:237) at android.app.ActivityThread.main (ActivityThread.java:8167) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100) Caused by: java.lang.NullPointerException: at com.davidbriglio.foreground.ForegroundService.onStartCommand (ForegroundService.java:16) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4534)

mirko77 commented 2 years ago

@LillyWebsites you could try this fork and report back https://bitbucket.org/epicollect/cordova-foreground-plugin/src/master/

LillyWebsites commented 2 years ago

I dont know how. Your fork still says: cordova plugin add cordova-plugin-foreground-service but thats the original. cordova plugin add cordova-foreground-plugin or cordova plugin add https://bitbucket.org/epicollect/cordova-foreground-plugin did not work last week

Failed to fetch plugin https://bitbucket.org/epicollect/cordova-foreground-plugin via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL.

mirko77 commented 2 years ago

@LillyWebsites try with npm install --save https://bitbucket.org/epicollect/cordova-foreground-plugin

LillyWebsites commented 2 years ago

@LillyWebsites try with npm install --save https://bitbucket.org/epicollect/cordova-foreground-plugin

npm ERR! code ENOENT npm ERR! syscall spawn git npm ERR! path git npm ERR! errno ENOENT npm ERR! enoent Error while executing: npm ERR! enoent undefined ls-remote -h -t https://bitbucket.org/epicollect/cordova-foreground-plugin.git npm ERR! enoent npm ERR! enoent npm ERR! enoent spawn git ENOENT npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

Is this way of installing perhaps not compatible with phonegap?

jinlee487 commented 1 year ago

any updates on this problem?

Creiger commented 1 year ago

Hi, i had the same problem and then i just added all params: icon, priority (1-3) and random id. Like this: cordova.plugins.foregroundService.start('App name', 'Message', 'icon', 3, 10);

And now there is no null Exceeption error. ;)

mirko77 commented 1 year ago

@Creiger

Always used this call


 cordova.plugins.foregroundService.start(
                        PARAMETERS.APP_NAME,
                        labels.loading,
                        'ec5_notification',
                        1,
                        10
                    );

and always crashes are reported on the Play Console