androidreact-nativeandroid-permissions

React native - Keeps adding android.permission.READ_PHONE_STATE


My app doesn't need to read phone state so I'd like to remove the permission from my react native app.

Every time i delete it from everywhere in the project, it is re-added again when I run ./gradlew assembleRelease

How do I get it to stop adding it in?


Solution

  • Use android manifest merging

    Add new file android/app/src/release/AndroidManifest.xml

    with contents

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

    Done! More about manifest merging: https://developer.android.com/studio/build/manifest-merge.html#merge_priorities , section Merge priorities