Android Question SD: Floating Button StandOut will crash in B4A 13.0 with SDK34

ppgirl

Member
Licensed User
Longtime User
@Star-Dust

When B4A13.0 uses SDK34 and android:targetSdkVersion="34" , your library will crash. There is a issue about "MissingForegroundServiceTypeException" in SDK34.

I know the useful library is too old and not maintained. I wonder if you have any improvements? Thanks.

There is the log -

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
*** Service (standout) Create ***
standout_service_create (java line: 522)
android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{a7b24e5 7489:b4a.example/u0a215} targetSDK=34
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:5075)
at android.os.Parcel.readParcelable(Parcel.java:5057)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3237)
at android.os.Parcel.createException(Parcel.java:3226)
at android.os.Parcel.readException(Parcel.java:3209)
at android.os.Parcel.readException(Parcel.java:3151)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7167)
at android.app.Service.startForeground(Service.java:776)
at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85)
at b4a.example.standout._service_create(standout.java:522)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at b4a.example.standout.onCreate(standout.java:69)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4976)
at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8699)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Service started in the background. Trying to start again in foreground mode.
*** Service (starter) Create ***
** Service (starter) Start **
Service started in foreground mode.
java.lang.RuntimeException: Unable to start service b4a.example.starter@f6b9049 with Intent { cmp=b4a.example/.starter (has extras) }: java.lang.RuntimeException: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{c46eb09 7566:b4a.example/u0a215} targetSDK=34
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5164)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2468)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8699)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.RuntimeException: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{c46eb09 7566:b4a.example/u0a215} targetSDK=34
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent(ServiceHelper.java:173)
at b4a.example.starter.handleStart(starter.java:102)
at b4a.example.starter.access$000(starter.java:8)
at b4a.example.starter$1.run(starter.java:74)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:240)
at b4a.example.starter.onStartCommand(starter.java:72)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5146)
... 9 more
Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{c46eb09 7566:b4a.example/u0a215} targetSDK=34
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:5075)
at android.os.Parcel.readParcelable(Parcel.java:5057)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3237)
at android.os.Parcel.createException(Parcel.java:3226)
at android.os.Parcel.readException(Parcel.java:3209)
at android.os.Parcel.readException(Parcel.java:3151)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7167)
at android.app.Service.startForeground(Service.java:776)
at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent(ServiceHelper.java:171)
... 15 more
 

Star-Dust

Expert
Licensed User
Longtime User
It is probably linked to the new requirements for services, these this thread

 
Upvote 0

ppgirl

Member
Licensed User
Longtime User
I try to add the line in mainfest , It can fix the crash. But it is a short time service and it will happen ANR in minutes because no place to adding "Service_Timeout(Params As Map)".

SetServiceAttribute(b4a.example.standout, android:foregroundServiceType, shortService)
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
You could try this suggestion from Erel
 
Upvote 0

ppgirl

Member
Licensed User
Longtime User
The crash issue is in the "Floating Button StandOut" library, It does not define the foreground service type. I have no source code to modify.

I am not sure which type foreground service is fit the case , even I have the source code.

------------------------------

If your app targets Android 14, it must specify appropriate foreground service types. As in previous versions of Android, multiple types can be combined. This list shows the foreground service types to choose from:

 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
As soon as possible, I will review the library and make appropriate changes.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Hi,
The problem is partially solved. It is necessary to add the service attribute and permission in the manifest as explained in this post.

When the library is compiled, adding the attribute in the manifest generates an error because it does not find the module because it is contained in the library.
So with the sources of the uncompiled library it works perfectly. Conversely it does not work with the compiled library.
I will update if there is any news on this.
 
Last edited:
Upvote 0
Top