gpt4 book ai didi

android - 禁用依赖权限

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:25:48 25 4
gpt4 key购买 nike

我现在面临以下问题:

我开发了应用程序“A”,它使用权限 1、2、3 并使用第三方库“B”作为依赖项(使用 maven 和 gradle 添加)。

库“B”使用权限 4 和 5。现在在构建应用时, list 合并将权限 4 和 5 添加到应用“A”。

我如何防止这种情况发生并在最终 list 中仅具有权限 1、2 和 3?

我的第一个猜测是使用一个明显的合并标记,如下所示:http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Markers

最佳答案

您需要使用 Selector

Each tools:node or tools:attr declaration can be augmented by a tools:selector attribute which is contextual information on whether or not the merging strategy should be applied to the current lower priority XML description. For instance, this is useful when removing a permission only if coming for one particular library as opposed to any library:

<permission
android:name="permissionOne"
tools:node="remove"
tools:selector="com.example.lib1">

根据您的初步要求,它会是下一个

<!--suppress AndroidDomInspection -->
<uses-permission
tools:node="removeAll"/>

但请记住,所有其他 <uses-permissions/>将被删除。

关于android - 禁用依赖权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27997679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com