Unable to start foreground services in android ionic

Viewed 517

I am trying to use foreground services in my app for background geolocation tracking. It was working fine suddenly it starts giving error after i change my package name

Here is there error

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.siloc.users, PID: 27987
    java.lang.RuntimeException: Unable to start service com.davidbriglio.foreground.ForegroundService@8094c49 with Intent { act=start cmp=com.siloc.users/com.davidbriglio.foreground.ForegroundService (has extras) }: java.lang.SecurityException: Not allowed to delete channel foreground.service.channel with a foreground service
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4432)

In my androidManifest file i can see foreground services are there

<?xml version='1.0' encoding='utf-8'?>
<manifest package="capacitor.android.plugins"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.amazon.com/apk/res/android">
<application  >
<service android:name="de.appplant.cordova.plugin.background.ForegroundService"/>
<service android:name="com.davidbriglio.foreground.ForegroundService" android:stopWithTask="true"/>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:name="android.hardware.location.gps" android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

In docs they says i need to add this in my config.xml file but i don't know where in the file

<platform name="android">
  <config-file parent="/*" target="AndroidManifest.xml">
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  </config-file>

my config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <access origin="*" />

  <feature name="BackgroundMode">
    <param name="android-package" value="de.appplant.cordova.plugin.background.BackgroundMode"/>
  </feature>
  <feature name="BackgroundModeExt">
    <param name="android-package" value="de.appplant.cordova.plugin.background.BackgroundModeExt"/>
  </feature>

  <feature name="Device">
    <param name="android-package" value="org.apache.cordova.device.Device"/>
  </feature>

  <feature name="ForegroundPlugin">
    <param name="android-package" value="com.davidbriglio.foreground.ForegroundPlugin"/>
  </feature>

  <feature name="Geolocation">
    <param name="android-package" value="org.apache.cordova.geolocation.Geolocation"/>
  </feature>

  <feature name="NetworkStatus">
    <param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager"/>
  </feature>

  <feature name="Whitelist">
    <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin"/>
    <param name="onload" value="true"/>
  </feature>


</widget>

https://ionicframework.com/docs/native/foreground-service

I am trying solve it from lst 2 days but not working any way. what should i do?

0 Answers
Related