【问题标题】:How to make android library uses-permission optional instead of required如何使android库使用权限可选而不是必需
【发布时间】:2019-04-10 22:35:22
【问题描述】:

我使用的其中一个库指定:

    <uses-feature android:name="android.hardware.camera" android:required="true" />

但我正在处理相机不可用的情况,所以我想将其设为 required="false"。

目前我只是将其完全删除

    <uses-feature android:name="android.hardware.camera" tools:node="remove" />

在我的清单文件中。这并不理想,因为它根本不会出现在合并的清单中。如何让它在合并的清单文件中显示为

    <uses-feature android:name="android.hardware.camera" android:required="false" />

?

【问题讨论】:

    标签: android android-manifest manifest android-library


    【解决方案1】:
    <uses-feature android:name="android.hardware.camera" android:required="false" tools:replace="required" />
    

    tools:replacereplaces a lower-priority attribute 所以应该给你你想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 2013-03-04
      • 1970-01-01
      • 2019-05-19
      • 2011-04-15
      • 2011-11-10
      • 2020-04-10
      相关资源
      最近更新 更多