This will happen if you have set targetSdkVersion = 28
(Android 9 / Pie) or above and have not declared the usage of the FOREGROUND_SERVICE
permission.
From the migration notes for Android 9:
Apps wanting to use foreground services must now request the
FOREGROUND_SERVICE permission first. This is a normal permission, so
the system automatically grants it to the requesting app. Starting a
foreground service without the permission throws a SecurityException.
The solution is to just add the following in AndroidManifest.xml
:
<manifest ...>
...
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
...
<application ...>
...
</manifest>