Android Question java.lang.IllegalStateException: Not allowed to start service Intent

Douglas Farias

Expert
Licensed User
Hi all.
i m posted this question here.
https://www.b4x.com/android/forum/t...n-not-allowed-to-start-service-intent.101861/

As Erel reported, this is not a bug.
- how can i disable the starter to start when app is in background? or its possible start the starter service in background mode os something like this to avoid the crash?
i use the starter, i want disable this only in background.


the crash logs are on the link.
this error is on targetsdk 26+, on 25- i dont have any problem.

how i got this error?
when my device is connected via USB, and the screen is off, and i press compile debug or release i see this crash and the debug stop.

to fix now, i put a option on my device to never sleep, screen is on every time.

I see this same log crash in the firebase with another devices, however I do not know how to produce this error in an apk generated without being connected to the USB cable.

i m tryed to reproduce this error with apk downloaded from google play and i dont find any crash.
i really dont know how my app users are getting this error. any ideia?

thx
 

DonManfred

Expert
Licensed User
Please post the full Stacktrace. Without it is is hard to ask questions to help.
 
Last edited:
Upvote 0

Douglas Farias

Expert
Licensed User
Please post the full Stacktrace. Without it is is hard to ask questions to help.
hi. its the same logs of the link on the first post.

log without filter.
Android Xlat is disabled
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=b4a.example/.main} from uid 2000
getTransport: Cannot find entry vendor.qti.hardware.iop@2.0::IIop/default in either framework or device manifest.
Iop tryGetService failed
activityStartTrigger: Activity is Triggerred in full screen ApplicationInfo{bd60309 b4a.example}
activityStartTrigger: not whiteListedb4a.example/b4a.example.main/1
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
activityResumeTrigger: The activity in ApplicationInfo{bd60309 b4a.example} is now in focus and seems to be in full-screen mode
activityResumeTrigger: not whiteListedb4a.example/b4a.example.main/1
Start proc 10404:b4a.example/u0a177 for activity b4a.example/.main
Not starting debugger since process cannot load the jdwp agent.
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
Reconfiguring input devices. changes=0x00000004
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
ActivityTrigger activityPauseTrigger
The ClassLoaderContext is a special shared library.
Connecting to perf service.
Class anywheresoftware.b4a.BA failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
common created.
Starting remote logger. Port: 35352
Skia GL Pipeline
ActivityTrigger activityStopTrigger
Background start not allowed: service Intent { cmp=b4a.example/.starter } to b4a.example/.starter from pid=10404 uid=10177 pkg=b4a.example startFg?=false
Shutting down VM
FATAL EXCEPTION: main
Process: b4a.example, PID: 10404
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=b4a.example/.starter }: app is in background uid UidRecord{1305be6 u0a177 TPSL idle change:idle|cached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
at android.app.ContextImpl.startService(ContextImpl.java:1532)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at anywheresoftware.b4a.keywords.Common$9.run(Common.java:880)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=b4a.example/.starter }: app is in background uid UidRecord{1305be6 u0a177 TPSL idle change:idle|cached procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
at android.app.ContextImpl.startService(ContextImpl.java:1532)
at android.content.ContextWrapper.startService(ContextWrapper.java:664)
at anywheresoftware.b4a.keywords.Common$9.run(Common.java:880)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
onSignalStrengthsChanged signalStrength=SignalStrength: 99 0 -120 -160 -120 -160 -1 25 -91 -8 200 2147483647 0 2147483647 99 255 2147483647 gsm|lte use_rsrp_and_rssnr_for_lte_level [-120, -115, -110, -100] [-113, -103, -97, -89] level=4
updateTelephony: hasService=true ss=SignalStrength: 99 0 -120 -160 -120 -160 -1 25 -91 -8 200 2147483647 0 2147483647 99 255 2147483647 gsm|lte use_rsrp_and_rssnr_for_lte_level [-120, -115, -110, -100] [-113, -103, -97, -89]
Force finishing activity b4a.example/.main
Sending signal. PID: 10404 SIG: 9
Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
WIN DEATH: Window{61e0a41 u0 b4a.example/b4a.example.main}
Process b4a.example (pid 10404) has died: cch CRE
kill(-10404, 9) failed: No such process
Successfully killed process cgroup uid 10177 pid 10404 in 0ms
Process 10404 exited due to signal (9)
setHasOverlayUi called on unknown pid: 10404
mCompatibilityFlags - 0
applicationDensity - 480
applicationScale - 1.0
failed to connect to socket 'tcp:6777': Connection refused
failed to connect to socket 'tcp:6778': Connection refused
received broadcast android.intent.action.BATTERY_CHANGED
handleBatteryUpdate
failed to connect to socket 'tcp:6777': Connection refused
failed to connect to socket 'tcp:6778': Connection refused
received broadcast android.intent.action.BATTERY_CHANGED
handleBatteryUpdate
failed to connect to socket 'tcp:6777': Connection refused
failed to connect to socket 'tcp:6778': Connection refused
failed to connect to socket 'tcp:6777': Connection refused
failed to connect to socket 'tcp:6778': Connection refused
received broadcast android.intent.action.BATTERY_CHANGED
handleBatteryUpdate
failed to connect to socket 'tcp:6777': Connection refused
failed to connect to socket 'tcp:6778': Connection refused
received broadcast android.intent.action.BATTERY_CHANGED
handleBatteryUpdate

thx
 
Upvote 0

Douglas Farias

Expert
Licensed User
What causes the starter service to start?
i think is when the main start. when main start it start the starter service too.

i get this error on all project. i can create a new project now, dont change any line of code and i will get this same crash.

to reproduce the error
- open a b4a (new project)
- connect the device with USB cable
- press debug or release button
- crash here. (the app dont start and i see the crash in log)

i see the crash when my screen is off (sleep) only.
when the screen is on i dont have crash.

thx
 
Upvote 0

DonManfred

Expert
Licensed User
i think is when the main start. when main start it start the starter service too.
Not really. The starter service WAS running and your app was in background. Something causes your STARTER Service to start. Maybe an Intentfilter? Or a Broadcastreceiver?
 
Upvote 0
Top