Bug? NB6 with SdkTarget 34 + Service with location attribute = Crash

Num3

Active Member
Licensed User
Longtime User
Hi all!

In NB6, when the target SDK is set to 34, and when calling Service.StartForeground(1, Starter.CreateNotification("...")) inside a service that has the location attribute,
the app crashes with this error:

B4X:
java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{ebd43a 17136:b4a.example1/u0a370} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION]  and the app must be in the eligible state/exemptions to access the foreground only permission

The permissions are set correctly, and all works well if the targetSDK is 33.

B4X:
SetServiceAttribute(TrackingService, android:foregroundServiceType, "location")
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddApplicationText(<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />)

I have narrowed the crash to this line in the Build sub of the NB6 library:
B4X:
Return NotificationBuilder.RunMethod("build", Null)

--EDIT--

Forgot to mention this service is first enabled and called in app, by user action
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…