I was trying to build my ionic app in android studio and receive this error
2021-07-04 15:58:42.279 11626-11626/com.siloc.users E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.siloc.users, PID: 11626
java.lang.RuntimeException: Unable to start service com.davidbriglio.foreground.ForegroundService@1d25633 with null: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4432)
at android.app.ActivityThread.access$2100(ActivityThread.java:259)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2142)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:230)
at android.app.ActivityThread.main(ActivityThread.java:7880)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
at com.davidbriglio.foreground.ForegroundService.onStartCommand(ForegroundService.java:16)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4414)
at android.app.ActivityThread.access$2100(ActivityThread.java:259)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2142)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:230)
at android.app.ActivityThread.main(ActivityThread.java:7880)
it seems like something is wrong with foreground services how i can fix this
it how i am using foreground service in my app
import { ForegroundService } from '@ionic-native/foreground-service';
ForegroundService.start('GPS Running', 'Background Service', 'drawable/fsicon');
AndroidMAnifest.xml
<application >
<service android:name="de.appplant.cordova.plugin.background.ForegroundService"/>
<service android:name="com.davidbriglio.foreground.ForegroundService" android:stopWithTask="true"/>
</application>
1 post - 1 participant