Android Question Solved - Error in anywheresoftware.b4a.keywords.Common.StartServiceImpl

Alex_197

Well-Known Member
Licensed User
Longtime User
I see that some of the users who use Android 12 (SDK 31) and Android 13 (SDK 33) are gettig this error.

Here is an error details
B4X:
Exception java.lang.RuntimeException:
  at anywheresoftware.b4a.keywords.Common$11.run (Common.java:1184)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8741)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by android.app.ForegroundServiceStartNotAllowedException:
  at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
  at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
  at android.os.Parcel.readParcelableInternal (Parcel.java:4784)
  at android.os.Parcel.readParcelable (Parcel.java:4752)
  at android.os.Parcel.createExceptionOrNull (Parcel.java:3018)
  at android.os.Parcel.createException (Parcel.java:3007)
  at android.os.Parcel.readException (Parcel.java:2990)
  at android.os.Parcel.readException (Parcel.java:2932)
  at android.app.IActivityManager$Stub$Proxy.startService (IActivityManager.java:6201)
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1967)
  at android.app.ContextImpl.startForegroundService (ContextImpl.java:1933)
  at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:839)
  at anywheresoftware.b4a.keywords.Common.StartServiceImpl (Common.java:905)
  at anywheresoftware.b4a.keywords.Common.StartService (Common.java:893)
  at anywheresoftware.b4a.keywords.Common$11.run (Common.java:1154)

At the same to no errors with Android 10 and Android 11. I don't have Android 12 or 13 phone so I can't reproduce this error.

My app uses Firebase for push messages and Crashlytics. Can it be related to this?

Just in case - here is my manifest

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="31"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
CreateResourceFromFile(Macro, Themes.LightTheme)
'Non-SSL permission
CreateResourceFromFile(Macro, Core.NetworkClearText)
'End of default text.

AddPermission (android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission (android.permission.READ_EXTERNAL_STORAGE)

'    FusedLocationProvider:

'    required manifest entry required for Google Play Services
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
    SetActivityAttribute(MessageDetails, android:windowSoftInputMode, adjustPan|stateHidden)
'Farebase
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)

How can I see what is in this line - at anywheresoftware.b4a.keywords.Common$11.run (Common.java:1184) ?
 
Last edited:

agraham

Expert
Licensed User
Longtime User
You already asked and I already told you. You can't but you don't need to. The stack trace shows you the reason for the problem.
Caused by android.app.ForegroundServiceStartNotAllowedException:
You seem to be starting a service when it is not allowed.
 
Upvote 0

Similar Threads

Top