Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native unnecessary Android user permissions automatically added on build?

Tags:

It seems like Read/Write external storage and Read phone state permissions are automatically added to the manifest on building the android apk. Are these necessary for all React Native android apps? Is there any way to remove these permissions?

Looking at the build/output/logs/manifest-merger-debug-report.txt I see:

android:uses-permission#android.permission.READ_EXTERNAL_STORAGE IMPLIED from `/***/android/app/src/main/AndroidManifest.xml:1:1-22:12 reason: org.webkit.android_jsc` requested WRITE_EXTERNAL_STORAGE 

It feels weird that I'll see these permissions being requested if I install the app from the Play store if I'm not using them.

like image 282
Mike Wazowski Avatar asked Nov 16 '15 04:11

Mike Wazowski


1 Answers

I have an answer.

AndroidManifest.xml

Add this to manifest which should be line 1

xmlns:tools="http://schemas.android.com/tools" 

It should look like this

<manifest xmlns:android="http://schemas.android.com/apk/res/android"        xmlns:tools="http://schemas.android.com/tools"       package="YOUR PACKAGE NAME"> 

Now you can remove the permissions with this

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" /> 

So my permissions for a simple app are

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" /> 

Don't remove SYSTEM.ALERT.WINDOW, you will have problems in development.

like image 68
parker Avatar answered Nov 22 '22 06:11

parker