Android Question Firebase Crash Report : Not allowed to start service Intent

tufanv

Expert
Licensed User
Longtime User
Hello,

I am seeing this error report sometimes from the firebase.

B4X:
Exception java.lang.RuntimeException: Unable to start service ct.canlidoviz.httputils2service@6ab6c9e with null: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=ct.canlidoviz/.starter }: app is in background uid UidRecord{ad44a1e u0a359 SVC idle procs:1 seq(0,0,0)}
android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3696)
android.app.ActivityThread.-wrap21 ()
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1801)
android.os.Handler.dispatchMessage (Handler.java:105)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6940)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
Caused by java.lang.IllegalStateException: Not allowed to start service Intent { cmp=ct.canlidoviz/.starter }: app is in background uid UidRecord{ad44a1e u0a359 SVC idle procs:1 seq(0,0,0)}
android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)
android.app.ContextImpl.startService (ContextImpl.java:1484)
android.content.ContextWrapper.startService (ContextWrapper.java:663)
anywheresoftware.b4a.keywords.Common.StartService (Common.java:884)
anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:211)
ct.canlidoviz.httputils2service.onStartCommand (httputils2service.java:69)
android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3679)
android.app.ActivityThread.-wrap21 ()
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1801)
android.os.Handler.dispatchMessage (Handler.java:105)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6940)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

What may be the reason for this ?

TY
 

tufanv

Expert
Licensed User
Longtime User
No , I don't start starter service and I don't use sticky intents as I dont know what they are. As I can see , there are not too many errors so it is not critical for now but I just wanted to know the reason.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Are you sending a HttpJob from Service_Create / Service_Start of the starter service?
no , service create only includes subscribetotopics and consent manager code. But in firebasemessaging service I am calling:
CallSubDelayed(Main,"tokenkaydet")
under subscribetotopics sub. nothing more.
 
Upvote 0

Toky Olivier

Active Member
Licensed User
Longtime User
Hi,
I received this from Firebase, what does it mean? Do I need to do something in B4A?

Back in March, we graduated Firebase Crashlytics out of beta and announced the retirement of Firebase Crash Reporting. We wanted to give you a final reminder that on September 9th, 2018, Firebase Crash Reporting will be fully retired and you will no longer have access to that part of the console or metrics associated with it.
If you haven’t already, be sure to upgrade to Crashlytics and add the Crashlytics SDK to your app(s). We recommend shipping this soon so that you don't have a gap in your crash reporting. Otherwise, you will lose crash reporting functionality for your app(s) on September 9th.
To get started, visit your project’s console, choose Crashlytics in the left navigation and click “Set up Crashlytics”
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
USers experiencing the problem is increasing. Theese are my subs :

B4X:
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    kvs.Initialize(File.DirInternal, "datam")
    analytics.Initialize
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
       Dim context As JavaObject 'depends on JavaObject
   context.InitializeContext
   CL.Initialize(context)
 
   consent.Initialize("consent")
    consent.AddTestDevice("1BF76F3B1F0A7BCAA2FE57E91364BE63")
'    consent.SetDebugGeography(True) 'comment for regular operation
    consent.RequestInfoUpdate(Array(""))
    Wait For consent_InfoUpdated (Success As Boolean)
    If Success = False Then
        Log($"Error getting consent state: ${LastException}"$)
    End If
    Log($"Consent state: ${consent.ConsentState}"$)
    Log("EU: " & consent.IsRequestLocationInEeaOrUnknown)
    Do While IsPaused(Main)
        Sleep(100)
    Loop
    CallSubDelayed(Main, "ConsentStateAvailable")
End Sub

Sub Service_Start (StartingIntent As Intent)
   

End Sub

Firebase messaging :

B4X:
Public Sub SubscribeToTopics
fm.SubscribeToTopic("general") 'you can subscribe to more topics
LogColor(fm.Token,Colors.Red)
Main.usertoken=fm.token
CallSubDelayed(Main,"tokenkaydet")
End Sub

sub tokenkaydet sends the token to my database online on a dedicated.
Based on these logs, the process has somehow started from HttpUtils2Service. Are you doing anything with HttpUtils2Service directly?
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I totally missed that. So should I add this to firebasemessaging module's start sub ?


B4X:
fm.HandleIntent(StartingIntent)
   Sleep(0) 'allow the MessageReceived event to be raised.
   Service.StopAutomaticForeground

it is currently :

B4X:
Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub

should I replace it with the first code or just add the first code after the above one ?
 
Upvote 0
Top