I have a library called com.example.library, containing a service called com.example.library.http.RestService. The library's manifest contains these elements:
<uses-permission android:name="com.example.library.permission.REST_PERMISSION" />
<permission
android:name="com.example.library.permission.REST_PERMISSION"
android:protectionLevel="signature" />
<application ...>
<service
android:name="com.example.library.http.RestService"
android:enabled="true"
android:permission="com.example.library.permission.REST_PERMISSION"
android:exported="true" >
<intent-filter>
<action android:name="com.example.library.LAUNCH_REST_SERVICE" />
</intent-filter>
</service>
</application>
I'm using that library in an app called com.example.testapp. TestApp's manifest repeats exactly the same elements as the library above. This works fine in the emulator running 4.0.3, and on a nexus 4 running 4.2.2, but when I try to use it on an HTC Wildfire S running 2.3.5, it falls over the moment it tries to launch the service, with the following exception:
java.lang.SecurityException: Not allowed to start service Intent
{ act=com.example.library.LAUNCH_REST_SERVICE pkg=com.example.testapp (has extras) }
without permission com.example.library.permission.REST_PERMISSION
I'm launching the service with the following code:
Intent intent = new Intent();
intent.setAction( "com.example.library.LAUNCH_REST_SERVICE" );
intent.setPackage( "com.example.testapp" );
[setting some extras]
startService( intent );
I've been scouring the web for help, and have read every related Stack Overflow question I can find, but just can't find anything I'm missing.