Android Permissions Problems

Hello!
For a while now I’ve been struggling with the permissions for Android Development. I want to get rid of the permissions GET_ACCOUNTS and READ_PHONE_STATE, since they are the only ones that force me to make a privacy policy for the Google Play Store. I do not do anything with the information given, and are default under the Engine. But I have found no way to change the permissions.

The first method that I came across was adding ManifestRequirementsOverride.txt to the “[Project Name]\Intermediate\Android\APK” file in your project file. However, the text document would not get rid of GET_ACCOUNTS and READ_PHONE_STATE, nor anything else that I wanted it to. In short, it wouldn’t override anything. I have tried it on multiple projects, each with the same output: no change to the AndroidManifest.xml file.
This is the answerhub post that I found it in: Removing Android app permissions - Programming & Scripting - Epic Developer Community Forums
Here’s a screenshot of my file setup before packaging my project, you can see the requirements for both AndroidManifest.xml and ManifestRequirementsOverride.txt. Packaging reverts AndroidManifest.xml to its original state.

The second method that I found was editing UE4’s source code. Supposedly, going to “Epic_Games\UE_4.15\Engine\Source\Programs\UnrealBuildTool\Android\UEDeployAndroid.cs” and changing the section that generated the manifest file will change the way that the manifest file generates. This doesn’t work, for me at least. I deleted the two Text.AppendLine that added in GET_ACCOUNTS and READ_PHONE_STATE, to no avail. I edited them in Microsoft Visual Studio. The edits remain even after packaging the game.
I found this method at the forum post: Any way to edit the AndroidManifest.xml Manually? - Mobile - Epic Developer Community Forums
Here’s a screenshot of the section of code that I modified:

I really have no idea what to do.

Any suggestions are appreciated.
Thanks.

1 Like

Editing UEDeployAndroid.cs should definitely work. Delete [PROJECT_FOLDER]/Intermediate/Build/Android and try again.

Hello ,
Thanks for replying! Unfortunately, deleting the Android file has no effect. It is the same as before. The UEDeployAndroid.cs file still shows the edits.

The easiest way to achieve this is to use UPL (“Unreal Plugin Language”) file to remove permissions. As I know, it’s not publicly documented, so you have to dig through UE4 source code to understand what it is capable of. Basically, UPL is an XML that allows to modify contents of Android- and iOS- specific files, such as AndroidManifest.xml or GameActivity.java.

  1. Create RemoveAndroidPermissions_UPL.xml file near the .Build.cs file of your project. It should contain this:

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

  1. Add

using System.IO;

to the import section of the .Build.cs file. Then add this code to the constructor:


if (Target.Platform == UnrealTargetPlatform.Android) {
  var manifestFile = Path.Combine(this.ModuleDirectory, "RemoveAndroidPermissions_UPL.xml");
  AdditionalPropertiesForReceipt.Add(
    new ReceiptProperty("AndroidPlugin", manifestFile)
  );
}

4 Likes

You can see how UPL is used in my plugins: gameDNAstudio (gameDNA) · GitHub but I think modifying UEDeployAndroid.cs also should help…

UPL as above works, but the reason you had trouble with ManifestRequirementsOverride.txt is it should be in your project’s Build/Android folder. It will get copied to Intermediate/Android/APK but it doesn’t look for it there.

BTW, this won’t be necessary for these two permission in 4.16; we removed them as the old reason for needing them is not longer valid.

Hello Chris Babcock,
Thanks for replying to my forum post, I’m glad that Staff spend time on the forums/answerhub to help idiots like me. I’m also pleased that the two permissions will be removed in 4.16. I placed ManifestRequirementsOverride.txt in my project’s Build/Android folder, but unfortunately all that it did was cause the building to end in an “Exit Code = 5”. I’ll attach the output log for it if you’d like to look at it.

endragorr & : I have not tried the UPL method yet. I’ve tried a variation of it before, but after messing up the source code I CTRL+Z’d for ages out of a panic. I shall update soon to tell whether or not it works.

Thank you for all of your replies!

Take out everything before the <uses-sdk> and after last <uses-permission>… you are closing off the tags. Try just this:


     <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="15"/>
     
     <uses-feature android:required="true" android:glEsVersion="0x00020000"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
     <uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
     <uses-permission android:name="android.permission.VIBRATE"/>
     <uses-permission android:name="com.android.vending.BILLING"/>

1 Like

This worked. Thanks for helping me through it. =)

I have the same problem. Can you please share with me if you could solve the problem?

Will this work with Blueprints? I’ve been struggling with this for almost a week now to get my game into AppLab

FYI - you have to have a space after the permission name or it won’t work.

android:name=“xxx” /> works
android:name=“xxx”/> doesn’t work

<androidManifestUpdates>
    <removePermission android:name="android.permission.WAKE_LOCK" />
    <removePermission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</androidManifestUpdates>

None of that worked for me.
I had to change AndroidManifest manually and use Gradle build bat to compile a new APK with changes. Only this way it works with Unreal Engine 5.3

Can you explain this process a little bit more please. I having issue building the apk.

In short, this is the process I used, but I think we need to find a working solution for UE5.

Change android manifest as you need
{Project dir}\Intermediate\Android\arm64\gradle\app\src\main

Use Gradle to build the app
{Project dir}\Intermediate\Android\arm64\gradle
gradlew.bat

Path to the compiled apk
{Project dir}\Intermediate\Android\arm64\gradle\app\build\outputs\apk\debug

This is not for publishing and more for development and testing.