我正在尝试在我的应用程序中使用前台服务进行后台地理位置跟踪。它工作正常,在我更改包名后突然出现错误
这里有错误
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)
在我的androidmanifest文件中,我可以看到前台服务在那里
<?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>
在文档中,他们说我需要将其添加到config.xml文件中,但我不知道文件中的位置
<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
我试图解决它从第一个2天,但没有任何工作方式。我该怎么办?
暂无答案!
目前还没有任何答案,快来回答吧!