React native - 不断添加 android.permission.READ_PHONE_STATE

React native - Keeps adding android.permission.READ_PHONE_STATE

我的应用程序不需要读取 phone 状态,所以我想从我的 React 本机应用程序中删除权限。

每次我从项目的任何地方删除它,当我 运行 ./gradlew assembleRelease

如何让它停止添加?

使用android清单合并

添加新文件android/app/src/release/AndroidManifest.xml

有内容

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    >
    <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
</manifest>

完成!有关清单合并的更多信息:https://developer.android.com/studio/build/manifest-merge.html#merge_priorities,部分 合并优先级