Removing Android app permissions

What’s the most straightforward way to remove some app permissions?

I noticed that on install my app asks for much more than it will ever use and I don’t want users to think that something shady is going on. I see the Extra Permissions section in the Android Settings, but I’m trying to remove permissions, not add them.

Thanks ahead of time.

Anyone?___

Same problem here…

And here…

Hey guys,

Good news, I got rid of all the permissions :slight_smile:
In your projectfolder go to GAME\Main\Intermediate\Android\APK.
You can look at the AndroidManifest.XML, and see all of the permissions.
You can’t change this file by simply deleting all the permissions, but here is what you do:

  1. Copy the important text in between
    ‘!–Requirements-- and
    /manifest’, like androidSDKversion etc (only essential stuff, and the permissions you want).
  2. Then, make a .txt file named ‘ManifestRequirementsOverride.txt’ in the GAME/Build/Android folder.
  3. Every line you will put in this file, will overwrite your AndroidManifest.XML-lines between ‘!–Requirements-- and
    /manifest’.
    So if you leave this file blanc, all permissions will be gone, but you will have some other problems when building…
    Thats why you need to keep in some of the sdk and feature stuff :wink:

Maybe you’ll need to adjust some things to make it work for your project, or put in some permissions that you do want to use. For example, I still put in the wake_lock, because it doesn’t even ask users for permission, and it’s a nice feature :slight_smile: After building the game, your project’s AndroidManifest.XML will be updated, and will not need any permissions.

Hope this helps! :slight_smile:

2 Likes

This is all i put in my ManifestRequirementsOverride.txt:

<uses-sdk android:minSdkVersion="9"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

Great thanks! It’s really work!

Awesome! Thanks a lot, now people won’t think that some random guy making games in his spare time is trying to harvest metadata

There is an elegant solution using the UPL mechanism, which allows you to modify android manifest and Activity class.

(1) Create a file YourProject/Source/YourProject/AndroidSanitizePermissions_UPL.xml with content:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns:android="http://schemas.android.com/apk/res/android">
	<androidManifestUpdates>
		<removePermission android:name="android.permission.ACCESS_NETWORK_STATE" />
		<removePermission android:name="android.permission.ACCESS_WIFI_STATE" />
		<removePermission android:name="android.permission.READ_PHONE_STATE" />
		<removePermission android:name="com.android.vending.CHECK_LICENSE" />
		<removePermission android:name="android.permission.GET_ACCOUNTS" />
	</androidManifestUpdates>
</root>

(2) In YourProject/Source/YourProject.Build.cs add:

var manifest_file = Path.Combine(ModuleDirectory, "AndroidSanitizePermissions_UPL.xml");
AdditionalPropertiesForReceipt.Add(
	new ReceiptProperty("AndroidPlugin", manifest_file)
);

Now the unnecessary permissions will be removed from manifest.

Very usefull, thx. but in my case it does not remove Read_Phone_Stat and Get_Account.
Do you you maybe know why?

Have you tried my method using UPL?
In my project it successfully removed READ_PHONE_STATE and GET_ACCOUNTS.

I tried it and it doesn’t work for me…
The Manifest file uses the same permissions as before.

When i look in the Output Log I see this:

UATHelper: Packaging (Android (ETC1)): [proguard] Warning: can’t write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])

I don’t know what I should do with that information, but it says it can’t write the Manifest…
Does anybody know something?

Thanks in advance!

I wanted to try your solution to this problem but i don’t know where to place the files, because i can’t find these 2 path’s in my project folders…

YourProject/Source/YourProject/AndroidSanitizePermissions_UPL.xml
YourProject/Source/YourProject.Build.cs

I have no “Source” - folder or anything similar there…
Could you please help me with this?

Thanks in advance!

I suppose the Source directory only exists for C++ projects. In order to try this method, you could start a C++ project or convert an BP-only project to a C++ one using existing tutorials.

(You should not need any C++ code though, just YourProject.Build.cs)

Thank you for that fast reply. :slight_smile:
I`ll give it a try the next days.

Ohh and btw. your link about the UPL mechanism is broken.

I found my self a solution for removing the permissions when you can’t use the ManifestRequirementsOverride.txt.
It is based on the post of MarcelBlanck (#3) but it works with the Launcher Version 4.14.3 and Blueprint projects.

You have to do this only once per Engine Version and after that you only have to add your needed permissions in the project settings. So no more ManifestRequirementsOverride.txt is needed anymore.

I will post a detailed instruction in february, but if you want to know it faster, you can text me.

The link is not broken. You just need to have a GitHub account and associate it with your Unreal one. Steps are here.

So I tried this and it didn’t work. I tried using the override and while the permissions are fixed, the game doesnt launch!! (just crashes on android). Any suggestions?

I have encountered a similar problem when removing the network permission - my question.
They said it will crash if you remove that permission in “Launch from editor”, but should be fine to remove it when you are building an APK.

I’d like a detailed instruction. I can’t get ManifestRequirementsOverride.txt to work anymore.