I have created an Android plugin for Unity3D. This plugin starts a background service by calling bindService(). To declare this service, I have put the <service>
element as a child of the <application>
element in the AndroidManifest.xml file of my android module. Then I created a jar file from the module and put it in Assets\Plugins\Android folder.
The problem is that the <service>
element is missing in the AndroidManifest file created by Unity. why is that?
Unity should have extracted my manifest from the jar file and have merged it with its own manifest file according to Unity documentation:
You can drop pre-compiled Android library projects into the Assets->Plugins->Android folder. Pre-compiled means all .java files must have been compiled into jar files located in either the bin/ or the libs/ folder of the project. AndroidManifest.xml from these folders will get automatically merged with the main manifest file when the project is built.
So the result manifest file should contain the <service>
element (but it does not as said before).
The following is my module and its manifest file:
I used the following gradle code (from here) to convert the module into a jar file:
task createJar(type: Copy) {
from('build/intermediates/bundles/default/')
into('libs/jars/')
include('classes.jar')
rename('classes.jar', 'locationPlugin.jar')
}
Note: My question is not a duplicate of this question. I'm not making custom manifest and I'm not modifying the manifest made by Unity. My question is about why unity does not merge the manifest of my compiled module (.jar file) into its own manifest.