Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding or overriding an AAR manifest

I am adding a library into my project. It comes packaged as an AAR. But it has a BroadcastReceiver that listens to a BOOT_COMPLETED starts a service. I don't want this behavior in my app. I would like it to start whenever the app starts. (This part is already done through the AAR, I assume in case the user force stopped the app).

Is there a way to either modify their manifest; or specify in Gradle not to merge their manifest (in which i'd have to declare their activities in my own manifest, I think); or to override their manifest and have a android:enabled="false for the BroadcastReceiver"?

I also would want to do it in the manifest or Gradle, because if I do it programmatically and if they install the app but never open it, the library service would start automatically next time the user reboots their phone.

like image 452
chekemp Avatar asked Aug 05 '15 16:08

chekemp


People also ask

Does AAR contain dependencies?

The aar file doesn't contain the transitive dependencies and doesn't have a pom file which describes the dependencies used by the module. It means that, if you are importing a aar file using a flatDir repository you have to specify the dependencies also in your project.

How do I fix a failed manifest merger?

Try adding the following labels to resolve the issue: Add the xmlns:tools line in the manifest tag. Add tools:replace= or tools:ignore= in the application tag.

How can you tell if a manifest is merged?

Even before you build your app, you can see a preview of what your merged manifest looks by opening your AndroidManifest. xml file in Android Studio, and then clicking the Merged Manifest tab at the bottom of the editor.


1 Answers

You could re-declare their BroadcastReceiver in your manifest and use android:enabled="false" followed by tools:node = "replace".

Also if you later want to enable it, you can by using the setComponentEnabledSetting() method inside of PackageManager.

like image 152
raukodraug Avatar answered Oct 30 '22 10:10

raukodraug