I have two apps, App A and App B, which share the same signature. App A contains an exported service that I want App B to bind to. Here are the specifics of my issue:
-
App A:
- Contains an exported service declared as follows in
AndroidManifest.xml
:<service android:name="com.example.appa.ServiceName" android:enabled="true" android:exported="true" android:permission="com.example.permission.EXPORTED_SERVICE" />
- The service is not started by default.
- Contains an exported service declared as follows in
-
App B:
- Declares the necessary permission in its
AndroidManifest.xml
:<uses-permission android:name="com.example.permission.EXPORTED_SERVICE" />
- Declares the necessary permission in its
Issue:
On a device running Android 11, App B fails to bind to the service in App A, returning false
. The relevant logcat
output is:
W ActivityManager: Unable to start service Intent { cmp=com.example.appa/com.example.appa.ServiceName } U=0: not found
However, App A can bind to its own service without issue. Furthermore, once App A has bound to its own service, App B can then successfully bind to the service.
Expectation:
I expect App B to be able to bind to App A’s service under any conditions, regardless of whether the service has been previously bound by App A.
Additional Context:
- Both apps share the same signature.
- The device is running Android 11.
- The service in App A is set to
exported=true
.
Questions:
- Why can App A bind to its own service even if it hasn’t been started, but App B cannot?
- What changes can I make to ensure that App B can bind to App A’s service without relying on App A to bind it first?
Any help or pointers would be greatly appreciated. Thank you!