square/reader-sdk-android-quickstart

SecurityException: Permission Denial: requires android.permission.FOREGROUND_SERVICE

hardikdhola opened this issue · 1 comments

library causes following exceptions because of Apps that target Android 9 (API level 28) or higher and use foreground services must request the FOREGROUND_SERVICE permission. This is a normal permission, so the system automatically grants it to the requesting app.

If an app that targets API level 28 or higher attempts to create a foreground service without requesting FOREGROUND_SERVICE, the system throws a SecurityException.

java.lang.RuntimeException: Unable to create service com.squareup.cardreader.dipper.FirmwareUpdateNotificationService: java.lang.SecurityException: Permission Denial: startForeground from pid=21256, uid=10358 requires android.permission.FOREGROUND_SERVICE

Caused by: java.lang.SecurityException: Permission Denial: startForeground from pid=21256, uid=10358 requires android.permission.FOREGROUND_SERVICE

HI @hardikdhola this is why we recommend not targeting API 27 or above as it can cause issues. Our documentation states:

Reader SDK is not supported on Android versions below API 19 (KitKat, 4.4). Square does not recommend targeting Android versions above API 27 (Oreo, 8.1) with Reader SDK.

Reference: https://docs.connect.squareup.com/payments/readersdk/build-on-android