Android的摇篮清单合并:覆盖“使用,允许'属性从图书馆未来摇篮、清单、属性、图书馆

2023-09-06 03:42:11 作者:南栀

有关我的应用程序,我发展与我使用这个最新的Andr​​oid Studio的依赖在它的摇篮文件:

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:

<使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>

由于这里和此处我可以覆盖从导入库中的活动的属性 XML声明。

As described here and here I can override attributes from the imported library’s activity XML declarations.

但我也重写清单 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>

也改变了&LT;许可&GT; 元素&LT;使用-许可&GT; 并没有帮助。 该应用程序还要求许可访问SC卡

Also changing the <permission> element to <uses-permission> did not help. The app still asks for permission to access the SC card.

我的主要的的Andr​​oidManifest.xml 的看起来像现在这样:

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
        ...

更新: 通过@CommonsWare建议的答复是工作。

Update: The suggested answer by @CommonsWare is working.

这只是我的工具:选择=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.

推荐答案

这将是一个&LT;使用-许可&GT; 元素,你会删除,不是&LT;许可&GT; 元素

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.