Remove android.permission.SYSTEM_ALERT_WINDOW

How can i remove this permission from APK without ejecting from expo? Is it possible?

Hi @13aminsadi

I am pretty sure this is possible with EAS Build and Config Plugins.

Config Plugins would normally be for e.g. adding a specific permission, but as far as I know, removing permissions is basically done in the same way as adding permissions, so I think a Config Plugin would work for this too.

The following page shows how it would be done in a plain React Native project:

And here is some info on modifying AndroidManifest.xml:

I’m not sure how to add the xmlns:tools="http://schemas.android.com/tools" attribute to the manifest tag, though. But maybe that will point you in the right direction.

1 Like

Can this not be removed from the app.json android.permissions key?

No, because android.permissions.SYSTEM_ALERT_WINDOW is a default permissions added by React Native.

I’ve just built an app with expo build:android -t apk. This app has android.permissions == []:

% jq '.expo.android.permissions' <app.json
[]

You can dump the permissions using aapt2:

% aapt2 dump permissions myapp.apk | grep SYSTEM_ALERT_WINDOW
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'

Then I compiled with eas build and checked the permissions with bundletool:

% bundletool dump manifest --bundle myapp.aab | grep SYSTEM_ALERT_WINDOW
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

As you can see, that despite the empty expo.android.permissions, android.permission.SYSTEM_ALERT_WINDOW is still included.

1 Like

Thanks so much for this amazing help. I’m trying to learn more about eas, and your posts over the feature request site was inspiring. I’m hoping to get to custom builds without eject soon.

1 Like