remove-unnecessary-android-permissions.mo

When you create a React Native applications some Android permissions will be asked to the user, even if your app doesn't do anything.

Those permissions are:

  • Read phone state

  • Read external storage

  • Write external storage

  • Draw over other apps

As you actually don't need them from the start of your project, you can remove them from the beginning not to scare your user.

N.B.: There's a related open issue on React Native's Github repository.

Prerequisites

Steps

  1. Understand what the permissions are for

By knowing why you need the permissions you'll know when you might have to add them back and why they're unnecessary to most projects.

Read phone state

According to the official Android docs:

Allows read only access to phone state, including the phone number of the device, current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device.

So you won't need it from scratch.

Read external storage & Write external storage

According to a comment on the issue:

It's not for AsyncStorage as it uses a SQLite DB under the hood, which doesn't require any permission. Even if it used another method of storage like SharedPreferences or the internal storage to store files, it shouldn't require any permission (See Storage Options).

So unless you want to explicitely access the external storage - which isn't used by default - you won't need it.

Draw over other apps

Allows an app to create windows using the type TYPE_APPLICATION_OVERLAY, shown on top of all other apps.

Basically this permission is needed in debug mode to show the error redbox error.

  1. Remove the permissions

You need to be able to toggle the SYSTEM_ALERT_WINDOW permission (draw over other apps) so that it is used in debug but not in release.

To do so, first in your android/app/build.gradle

Then in your android/app/src/main/AndroidManifest.xml:

And then you can remove all the other permissions:

Troubleshooting

If you've never built your Android app before (e.g. newcomer or after destroying your project) you'll get errors like

To fix it you have to remove the lines you've added in the Manifest i.e.:

Then build your project once and add the lines back.

Last updated