FOREGROUND_SERVICE_DATA_SYNC added to Android Manifest but I'm not using a foreground service

I’m currently in the process of publishing my game to the PlayStore for testing.
The developer console is warning: You have undeclared foreground service permissions.
The specific permission is FOREGROUND_SERVICE_DATA_SYNC. I have not added this to the manifest so it must be something that Unity has done.
As far as I’m aware there are no foreground services in use in my game. The game is pretty standard for a Unity game. The only notable addons are Unity Legacy Ads and Unity’s In App Purchasing.
Related to data sync, I’m also using the c# HttpClient and UdpClient for in game value saving and online gameplay respectively. These are only connecting while the game is running.
As far as I can see neither would be running a foreground service.
The problem is that the developer console wants a video of the foreground service in use to verify if it is being used properly. Without knowing what the service is, making the video is a bit difficult.

If this permission is not needed is there a way to remove it from the android manifest?

Does anyone know where the permission is being added from?

Does anyone have any advice as to how to resolve this?

Any help or suggestions would be appreciated.

Quick update: I’ve built an APK from Unity and extracted the Android Manifest using apktool. This doesn’t have the same permissions. However if I build an AAB and use bundletool to extract the APKs the manifest in the base-master.apk does have the permissions.

I would be exporting the project to Android Studio but I have scripts that do processing during the build that I don’t think would work from android studio.

Any ideas?

NM. I got it to work. Here is another answer from Unity.

Did removing these permissions solve your problem and did you manage to release the new version without any problems?

Finally found a solution to this from this tread:

Adding these lines to the custom manifest solves the problem:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" tools:node="remove" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICEDATA_SYNC" tools:node="remove" />

I’ve still got no idea what causes the problem in the first place but it looks like a bug in Unity IAP.

Thanks for the answer. I keep adding this to the AndroidManifest under Plugins and it still not working for me. Is that the file I need to add the code to?

This is how I am doing it, is this correct?

// paste xml code here

You also need to enable Custom Main Manifest in project settings.


This is the correct way. What you have is a typo and that is why it was not working for me.