Android的摇篮清单合并:覆盖“使用,允许'属性从图书馆未来 [英] Android Gradle Manifest Merger: Override 'uses-permission' attribute coming from a library

查看:257
本文介绍了Android的摇篮清单合并:覆盖“使用,允许'属性从图书馆未来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的应用程序,我发展与我使用这个最新的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/>

由于这里和<一个描述 href="http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Override-an-attribute-coming-from-a-library"相对=nofollow>此处我可以覆盖从导入库中的活动的属性 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.

这篇关于Android的摇篮清单合并:覆盖“使用,允许'属性从图书馆未来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆