For my app that I'm developing with the latest Android Studio I'm using this dependencies within it's gradle file:
dependencies {
compile 'com.android.support:support-v4:21.0.+'
compile 'com.helpshift:android-aar:3.7.1'
}
The com.helpshift:android-aar:3.7.1
library needs the following permission for a feature that I don't use in my main app:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
As described here and here I can override attributes from the imported library’s activity XML declarations.
But can I also override manifest XML declarations like the mentioned uses-permission
?
I already tried something like this in my main manifest, but it didn't work:
<permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:node="remove"
tools:selector="com.helpshift">
</permission>
Also changing the <permission>
element to <uses-permission>
did not help. The app still asks for permission to access the SC card.
My main AndroidManifest.xml looks like this now:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
xmlns:tools="http://schemas.android.com/tools"
package="com.bmi.rechner" >
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:node="remove"
tools:selector="com.helpshift">
</uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
...
Update: The suggested answer by @CommonsWare is working.
It's just my tools:selector="com.helpshift"
which isn't correct. I'm leaving it out because I'm sure I won't need that permission in any other libraries for a while.
He also filed a feature request to improve the Manifest Merger Report which might help to find the right selector in the future.