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.
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With