问题描述
限时送ChatGPT账号..对于我使用最新的 Android Studio 开发的应用程序,我在它的 gradle 文件中使用此依赖项:
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'
}
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"/>
如此处和here 我可以覆盖来自导入库的属性活动 XML 声明.
As described here and here I can override attributes from the imported library’s activity XML declarations.
但我是否也可以像前面提到的uses-permission
那样覆盖manifest XML 声明?
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>
还将
元素更改为
也没有帮助.应用仍会要求获得访问 SC 卡的权限.
Also changing the <permission>
element to <uses-permission>
did not help. The app still asks for permission to access the SC card.
我的主要 AndroidManifest.xml 现在看起来像这样:
My main AndroidManifest.xml looks like this now:
<manifest xmlns:android="http://schemas.android/apk/res/android"
android:installLocation="auto"
xmlns:tools="http://schemas.android/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
...
更新:@CommonsWare 建议的答案是有效的.
Update: The suggested answer by @CommonsWare is working.
这只是我的 tools:selector="com.helpshift"
不正确.我将它排除在外是因为我确信我在一段时间内不需要任何其他图书馆的许可.
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.
推荐答案
这将是一个
元素,您可以删除
,而不是
元素.
It would be a <uses-permission>
element that you would remove
, not a <permission>
element.
请注意,如果您的应用没有此权限,库可能会崩溃.
And note that the library may crash if your app does not hold this permission.
这篇关于Android Gradle Manifest Merger:覆盖来自库的“uses-permission"属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论