Matt S. Member Licensed User Sep 28, 2025 #1 I tested MediaChooser with Sdk 35 and got an error: The attached example (Erel's one) will give this error if you change the targetSdkVersion to 35. ************************************************** Error occurred on line: 24 (KeepRunningService) java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:1135) at b4a.example.mediachooser$ResumableSub_StartForegroundService.resume(mediachooser.java:645) at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157) at anywheresoftware.b4a.BA.raiseEvent(BA.java:201) at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43) at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1801) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:342) at android.app.ActivityThread.main(ActivityThread.java:9634) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929) Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336) at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:282) ... 21 more Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318) ... 22 more Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{6165cd7 27978:b4a.example/u0a855} targetSDK=35 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:5090) at android.os.Parcel.readParcelable(Parcel.java:5072) at android.os.Parcel.createExceptionOrNull(Parcel.java:3252) at android.os.Parcel.createException(Parcel.java:3241) at android.os.Parcel.readException(Parcel.java:3224) at android.os.Parcel.readException(Parcel.java:3166) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7410) at android.app.Service.startForeground(Service.java:776) at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85) at b4a.example.keeprunningservice._start(keeprunningservice.java:170) ... 24 more ************************************************** Attachments MCExample.zip MCExample.zip 182.4 KB · Views: 224
I tested MediaChooser with Sdk 35 and got an error: The attached example (Erel's one) will give this error if you change the targetSdkVersion to 35. ************************************************** Error occurred on line: 24 (KeepRunningService) java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:1135) at b4a.example.mediachooser$ResumableSub_StartForegroundService.resume(mediachooser.java:645) at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157) at anywheresoftware.b4a.BA.raiseEvent(BA.java:201) at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43) at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1801) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:342) at android.app.ActivityThread.main(ActivityThread.java:9634) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929) Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336) at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:282) ... 21 more Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318) ... 22 more Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{6165cd7 27978:b4a.example/u0a855} targetSDK=35 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:5090) at android.os.Parcel.readParcelable(Parcel.java:5072) at android.os.Parcel.createExceptionOrNull(Parcel.java:3252) at android.os.Parcel.createException(Parcel.java:3241) at android.os.Parcel.readException(Parcel.java:3224) at android.os.Parcel.readException(Parcel.java:3166) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7410) at android.app.Service.startForeground(Service.java:776) at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85) at b4a.example.keeprunningservice._start(keeprunningservice.java:170) ... 24 more **************************************************
Erel B4X founder Staff member Licensed User Longtime User Sep 28, 2025 #2 You missed the comment about the foregroundServiceType. I've updated the example to include it.
Matt S. Member Licensed User Sep 28, 2025 #3 Erel said: You missed the comment about the foregroundServiceType. I've updated the example to include it. Click to expand... You are right. I missed that hint. Now everything is Ok! Thanks a lot!
Erel said: You missed the comment about the foregroundServiceType. I've updated the example to include it. Click to expand... You are right. I missed that hint. Now everything is Ok! Thanks a lot!