Unity removes "android.permission.INTERNET" in the build.apk after build is completed

I changed my Unity version to 2023.2.1.f1. But if you do not want to change your Unity version, you can download package for here.
https://download.packages.unity.com/com.unity.xr.openxr/-/com.unity.xr.openxr-1.9.1.tgz

I’m having the same issue, except i am working on the Pico 4 right now, and only because i develop for both Pico and Occulus (on an unrelated project) did i even catch that. If i only had the Pico 4 i would never have though that an Oculus related option even affects a different device, and i still find that to be rather odd.

The Pico openxr sdk does not yet support the 1.9.1 package, so i guess i try to downgrade my engine then to something that still supports 1.7.0 then? I gonna try that next.

I had it working temporarily last night by jumping through a bunch of hoops suggested here, but as mentioned above the checkbox keeps reenabling itself.

I just wanted to mention that even the Pico4 is affected by that, in case someone googles for a solution.

I have the same problem with Pico 4 … did you work around it somehow?

Big Thanks man! After 3 weeks of hard time and when I gave up god gives me you )

for anyone who still has this issue, one way around it is to manually change the androidmanifest in the apk by installing a program (i used apk editor studio) and open the apk contents, change the file, then save it as an apk again

I still have this issue and none of the fixes in this thread worked

I still have this issue and non of the fixes in this thread helped me. What exactly do I have to add in the androidmanifest? Just as it was stated at the top of this thread?

Same, my manifest does have the permission required, however, it still can not use tcp and when trying to look at it’s ip address, it gives me the 127.0.0.1 localhost address.

I faced the same issue and unchecking the Force Remove Internet didn’t fix it.
However I find another way to be sure the that the permission is properly set by knowing that Unity generates the Android Manifest based o.a. the player settings.
I’ve set Internet Access to “Require” in the Projects Settings > Player > Android > Other Settings | Configuration


Hope it will helps some of you.

Using @vzabladowski 's solution, of setting Internet access to Require, I found that I my manifest file now has the Internet permission. However my app still does not connect to the internet. When I run the following code it works in the editor but gives me a Cannot Resolve Destination Host error when running in a build.

private IEnumerator TestNetworkConnectivity()
{
    UnityWebRequest request = UnityWebRequest.Get("https://www.google.com");
    yield return request.SendWebRequest();

    if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
    {
        Debug.LogError("OLILOG Network Test Error: " + request.error);
    }
    else
    {
        Debug.Log("OLILOG Network Test Success: " + request.downloadHandler.text);
    }
}

I’ve had the same problem, finally got it to work following the recommendations.
Using Unity 2022.3.17f1 and OpenXR Plugin 1.9.1
It seems that even though you use a custom Android manifest with internet permission requested, and also, change the player settings to require internet, and also, unchecked the Meta Quest support force remove internet option; if you open the build’s Android manifest, there’s no trace of internet permission request.
Manually added the permission using APK Editor Studio.

How the hell is this STILL an issue in 2024? Who the F looks at an SDK for building a modern app and thinks “yeah you know what apps do NOT need? the goddamn internet”.

Presumably a whole bunch of fully qualified software engineers looked at the idea of force removing internet permissions by default and gave it a green light. Insane.

For People having Connection Issues with Open XR and Pico 4 , follow what has been done on this thread.

I was able to test and confirm its usage.

Unity Version : 2022.3.17f1
Open XR Version : 1.8.2

Hi All, Thanks a lot to this post for helping me fix this issue. I am adding here what worked for me:

  1. Tested on Unity 2022.3.50 f1, XR input Management 4.5.0, Open XR Plugin 1.12.1, Unity OpenXR Meta 1.0.2, Meta Quest 3
  2. After trying everything mentioned on this post, nothing worked for me, but after updating all the packages to above (latest during the time of writing this post), unchecking the Force remove internet permissions : android manifest still not had the line <uses-permission android:name="android.permission.INTERNET">, so added it manually using the APK Editor Studio ( APK Editor for PC and Mac – APK Editor Studio), saved the apk and deployed the apk to meta quest 3 headset NOT using the Meta Quest Developer Hub but using APK Editor Studio only (keep the headset plugged in via link cable : similar to MQDH).

so angry at this. lost countless hours trying to figure out what was going on till i saw this thread. not only a seriously bad idea but they then confounded it by burying the option and then bugged up the button to undo their bad idea. Unbelievable

I need to STRONGLY appreciate you. I tried many ways to make it connect to the server, but it was just because of “Force Remove Internet”. Thank you again!

make internet access : auto
and uncheck the force remove internet as they said befor

【The Ultimate Solution】
In short, if you tried all the things mentioned on this page and still don’t have the internet permission for your app, try either of these two:

  1. Manually added the permission using APK Editor Studio.
  2. Write a post gradle callback script to force include the internet permission.

I’m gonna talk about the second one.

After being troubled by this silly bug, I finally got the internet permission. I’m building a TCP client on Meta Quest 3s.
Using Unity 2022.3.52f1 and OpenXR Plugin 1.9.1
Same as @aSyry I use a custom Android manifest with internet permission requested, change the player settings to Require, and unchecked the Meta Quest support force remove internet option. Still got internet access denied.

My final solution is to write a post gradle callback script to force include the internet permission. And to save your time, here’s how to do it.

Step 1. In your Unity project, under Assets/Editor, create a new file:
Assets/Editor/PostBuildInjectInternetPermission.cs

Step 2. Paste this code:

#if UNITY_ANDROID
using System.IO;
using UnityEditor;
using UnityEditor.Android;

public class PostBuildInjectInternetPermission : IPostGenerateGradleAndroidProject
{
    public int callbackOrder => 1000;

    public void OnPostGenerateGradleAndroidProject(string path)
    {
        // Path to final AndroidManifest.xml in the Gradle project
        var manifestPath = Path.Combine(path, "src", "main", "AndroidManifest.xml");

        if (!File.Exists(manifestPath))
        {
            UnityEngine.Debug.LogError("AndroidManifest.xml not found: " + manifestPath);
            return;
        }

        string manifest = File.ReadAllText(manifestPath);

        string permissionLine = "<uses-permission android:name=\"android.permission.INTERNET\" />";
        if (!manifest.Contains(permissionLine))
        {
            int insertIndex = manifest.IndexOf("<application");
            if (insertIndex != -1)
            {
                manifest = manifest.Insert(insertIndex, permissionLine + "\n    ");
                File.WriteAllText(manifestPath, manifest);
                UnityEngine.Debug.Log("[PostBuild] Injected INTERNET permission into AndroidManifest.xml");
            }
            else
            {
                UnityEngine.Debug.LogError("Failed to inject INTERNET permission: <application> tag not found.");
            }
        }
    }
}
#endif

If anyone wants something of a generic solution to handle permissions on both iOS and Android with a unified API, give Permissions Kit a try. It’s free and open source!

Let us know if you have any feedback!

After 8-9 hours, I finally found this thread for my friend and the first solution fixed it. Thank you so much, and OpenXR, shame on you.

Thanks SOOOOO MUCH @kaiangwen !!!

I tried everything - including APK Editor Studio, but nothing worked until I used the PostBuildInjectInternetPermission.cs script.

Works like a dream and you can just drop it into your Unity project and forget about it.