Android Question Missing foreground service type - Google Play Crash Report

cooperlegend

Active Member
Licensed User
Longtime User
I am getting old and struggling to keep up with recent changes.

Please help

Google Play is reporting "Missing foreground service type" to me

Problem
Your app or a library it uses tried to start a foreground service without declaring a service type

Recommendation
Declare the foreground service type in the manifest file and include it in the startForeground() call

My App uses firebase messaging to notify the App to update at various point.

I don't under stand what they are referring to (Background/Foreground ?)

What do I need to add, trawling though this forums suggests either

SetServiceAttribute(Starter, android:foregroundServiceType, shortService)
Private Sub Service_Timeout(Params As Map)
Service.StopForeground(NotificationId)
End Sub

or

AddPermission(android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING)
SetServiceAttribute(Starter, android:foregroundServiceType, "remoteMessaging")

The first wont compile as NotificationId is not declared !!?!
 

cooperlegend

Active Member
Licensed User
Longtime User
Hence my first statement :)

Thanks for your help. But I still haven't a clue what I need to add. I have several Apps, some use firebase messaging, some use GPS, some use bluetooth. Google Play just states a standard message

"Missing foreground service type

From Android 14, developers must specify service types when foreground services are found in their app's manifest. A version of your app that is currently in production is crashing because it tries to start a foreground service when no foreground service type is declared. Make sure that service types for the services that start in the foreground are specified in your app's manifest."

So simply , I ask , can anyone help me fix this issue. Plain simple help would be much appreciated with an explanation.
Thanks
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I'll try one last time (I'm not an expert on this topic).

If your app HAS a foreground service (search on site to find out what it is; in short, a service module with a notification), then you must declare in the Manifest file what type of that foreground service is.

Since you don't know them, you certainly have never added them to your projects. In this case, however, it is the Firebase Messaging library that has a foreground service, so only in this app of yours you must write in the Manifest File:
B4X:
AddPermission(android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING)
SetServiceAttribute(FirebaseMessaging, android:foregroundServiceType, "remoteMessaging")
 
Upvote 0

cooperlegend

Active Member
Licensed User
Longtime User
OK, It is starting to make more sense now, thanks

So it is the libraries that I am using like firebase, bluetooth, GPS that have foreground notification that it needs informing of ?

Wil SetServiceAttribute(Starter, android:foregroundServiceType, shortService) cover all of these rather than having to be specific ?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
1) SetServiceAttribute() needs to refer to the foreground service(s) causing the problem.
2) the "shortService" attribute may or may not be accepted. it depends on the service(s).
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
it appears that google is telling you that one of your apps is crashing due to the missing foreground service type exception. that you submitted an app which doesn't run for publication is hard to believe, but if google says it's crashing, it must be crashing. run it yourself and log the crash.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
have you told google? are all parties talking about the same app? you are allowed to ask for clarifications.
 
Upvote 0
Top