cordova-plugin-foreground-service icon indicating copy to clipboard operation
cordova-plugin-foreground-service copied to clipboard

Application crashes java.lang.NullPointerException

Open mirko77 opened this issue 3 years ago • 9 comments

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

mirko77 avatar Sep 28 '21 08:09 mirko77

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 avatar May 15 '22 07:05 LillyWebsites

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)

LillyWebsites avatar May 15 '22 08:05 LillyWebsites

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

mirko77 avatar May 15 '22 08:05 mirko77

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.

LillyWebsites avatar May 22 '22 07:05 LillyWebsites

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

mirko77 avatar May 23 '22 11:05 mirko77

@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?

LillyWebsites avatar May 24 '22 11:05 LillyWebsites

any updates on this problem?

jinlee487 avatar Aug 28 '23 15:08 jinlee487

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. ;)

Creiger avatar Sep 04 '23 13:09 Creiger

@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

mirko77 avatar Sep 05 '23 09:09 mirko77