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

7

0

Afternoon,
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?

Vadose answered 12/1 at 8:58 Comment(0)
P
0

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

Correct: FOREGROUND_SERVICE_DATA_SYNC
Incorrect: FOREGROUND_SERVICEDATA_SYNC

Pneumato answered 12/2 at 20:12 Comment(1)

You are indeed correct. My appologies.

Vadose
V
0

Finally found a solution to this from this tread: https://forum.unity.com/threads/foreground_service-permission-added-automatically.974304/

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.

Vadose answered 4/2 at 22:16 Comment(0)
P
0

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?

Pneumato answered 4/2 at 21:2 Comment(0)
P
0

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

// paste xml code here

Pneumato answered 4/2 at 22:16 Comment(0)
P
0

NM. I got it to work. Here is another answer from Unity.
https://forum.unity.com/threads/removing-foreground_service_data_sync-permission.1543283/#post-9627467

Pneumato answered 6/2 at 16:52 Comment(0)
V
0

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

image

Vadose answered 9/2 at 15:53 Comment(0)
P
0

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

Correct: FOREGROUND_SERVICE_DATA_SYNC
Incorrect: FOREGROUND_SERVICEDATA_SYNC

Pneumato answered 12/2 at 20:12 Comment(1)

You are indeed correct. My appologies.

Vadose
S
0

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

Sackbut answered 15/2 at 16:19 Comment(1)

yes it finally worked

Pneumato

© 2022 - 2024 — McMap. All rights reserved.