I'm currently developing a plugin for ATAK in which I need to launch a handful of services that have been imported from other modules I've created. When I try to start the services however, I receive the error as stated in the title. I'm a bit confused as the services I've created do include the BIND_JOB_SERVICE permission in both the module itself and plugin AndroidManifests as follows
<service
android:name="mqtt.MqttBrokerService"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="mqtt.MqttBrokerService"></action>
</intent-filter>
</service>
These code blocks are within the application section of the AndroidManifest so that isn't the issue. I'm pretty dumbfounded and not sure why this happening and also why it even requires this permission since it isn't a job service. The cherry on top is I created a sample app that has the exact same Manifest as my plugin and the sample app launches the services just fine. The only difference is in my plugin, I don't launch the services from the main activity as follows
Intent startMqtt = new Intent("mqtt.MqttBrokerService");
startMqtt.setPackage("com.atakmap.android");
getMapView().getContext().startForegroundService(startMqtt);
When you declare a
Servicewith a permission in the manifest, this tells Android that any code that wants to use yourServicemust hold the specified permission. The error you are getting indicates that some code is trying to use theServiceand that code does not hold the permissionandroid.permission.BIND_JOB_SERVICE.The permission
android.permission.BIND_JOB_SERVICEis used by theJobSchedulerso I'm thinking that you are trying to use thisServicedirectly and not via theJobScheduler.