Recently I have been getting this crash report in play console.."Exception java.lang.RuntimeException:" the reason it says is
"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
But I don't have any code in my starter service..I am using scaleimageview, admob etc as libraries...so could it be due to any of these libraries or is there any way to check which lib is causing the issue that starts the foreground service..please help...below is my starter service code
Strater service code:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Thanks Erel,
I am using B4A version 13.10, No push notification, I am not using any other service
This is my error 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 service types for the services that start in the foreground are specified in your app's manifest.
Vulnerable users
50.39%
B4X:
Exception java.lang.RuntimeException:
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5286)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2531)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
Caused by java.lang.RuntimeException:
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent (ServiceHelper.java:173)
at com.growth.chart.starter.handleStart (starter.java:102)
at com.growth.chart.starter.access$000 (starter.java:8)
at com.growth.chart.starter$1.run (starter.java:74)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:240)
at com.growth.chart.starter.onStartCommand (starter.java:72)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5268)
Caused by android.app.MissingForegroundServiceTypeException:
at android.app.MissingForegroundServiceTypeException$1.createFromParcel (MissingForegroundServiceTypeException.java:53)
at android.app.MissingForegroundServiceTypeException$1.createFromParcel (MissingForegroundServiceTypeException.java:49)
at android.os.Parcel.readParcelableInternal (Parcel.java:4882)
at android.os.Parcel.readParcelable (Parcel.java:4864)
at android.os.Parcel.createExceptionOrNull (Parcel.java:3064)
at android.os.Parcel.createException (Parcel.java:3053)
at android.os.Parcel.readException (Parcel.java:3036)
at android.os.Parcel.readException (Parcel.java:2978)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:7234)
at android.app.Service.startForeground (Service.java:775)
at anywheresoftware.b4a.objects.ServiceHelper.StartForeground (ServiceHelper.java:85)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent (ServiceHelper.java:171)
Can you post the complete code in the starter service?
Something is causing the starter service to be started when the app is in the background. Are you using StartServiceAt? Any other intent filter? Only you can know...
Thanks Erel,
Previously I had file provider inialization in starter service, but after seeing this error i moved it to activity main..below is my starter service code..Is there any way to check while debugging what starts the starter service..Could it be due to the lib scaleimageview or admob..or can i randomly declare all the service type in my manifest and see if the error persits...
starter service code:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
I got the similar error "MissingForegroundServiceTypeException" in Crashlytics:
B4X:
Fatal Exception: java.lang.RuntimeException:
Unable to start service br.com.myprofiles.starter@db24804 with Intent { cmp=br.com.myprofiles/.starter (has extras) }:
java.lang.RuntimeException: android.app.MissingForegroundServiceTypeException: Starting FGS without a type
callerApp=ProcessRecord{c533f62 30832:br.com.myprofiles/u0a339} targetSDK=34
and the warning "Missing foreground service type" in the Play Console.
Thanks..
It is not a warning in fact everything is fine when the app is verified...The error occurs after the crash..Today Two devises OnePlus OP5961L1 and samsung a13 is shown in the crash report....Shal I try 'asales' solution..
Thanks..
It is not a warning in fact everything is fine when the app is verified...The error occurs after the crash..Today Two devises OnePlus OP5961L1 and samsung a13 is shown in the crash report....Shal I try 'asales' solution..
No ..That did not solve my problem..You can refer to my new thread on the solution that i found out, which is working fine and play console is not showing exception.. I dont know if that is the right approach, request @Erel to kindly clarify..
Hi, Referring to my previous question above, after lot of research, I think I found the issue ... Though my manifest editor did not show any line related to foreground service, I checked the compiled manifest.xml file inside the Objects folder and found this line: I understand that this...