Hi, I am building a TCP Client VR application that is being deployed to the Meta Quest Pro. Initially I was getting a SocketException of Access Denied and after doing a little research I found out that I need to add the following statement to my AndroidManfiest.xml, which I did: <uses-permission android:name="android.permission.INTERNET" />
I am using 2022.3.5f1 version for the editor. My application initiates a socket connection to a server hosted on my local machine. Both headset and the local machine are connected to the same wi-fi and the application works completely fine on the local machine (tested using XR Simulator that comes with the OpenXR plug-in). I have also tried to access the server’s frontend from the headset’s browser using the local machines IP and that works fine as well.
I have also set the “Internet Access” to “Require” from “Auto” which gives me the following warnings after build is completed:
Library\Bee\artifacts\Android\Manifest\LauncherManifestDiag.txt: Unable to find Unity activity in manifest. Some attributes may not be set properly and need to be set manually.
Library\Bee\artifacts\Android\Manifest\LauncherManifestDiag.txt: Unity is trying to add element uses-permission#android.permission.INTERNET but it is already declared by the user in Assets/Plugins/Android\AndroidManifest.xml.
Library\Bee\artifacts\Android\Manifest\LauncherManifestDiag.txt: Unity is trying to add element uses-permission#android.permission.ACCESS_NETWORK_STATE but it is already declared by the user in Assets/Plugins/Android\AndroidManifest.xml.
2 & 3 makes sense as I did add those permissions manually. I do not know if I should be worrying about 1.
Here is the main issue that I believe is causing the socket connection to fail. After I built to my headset and decompile the latest build.apk, the AndroidManifest.xml in the build.apk looks like this:
<?xml version="1.0" encoding="utf-8"?>
As you can see, the tag for INTERNET permission is missing in the file. It seems as if it gets removed during the build. I have tried a bunch of methods and have spent almost 9 hours now trying to figure out what is going wrong and creating new builds show the same behavior of AndroidManifest.xml not having the INTERNET permission.
My sincerest apologies for the long post.
I greatly appreciate any assistance that can be offered.
Also, I am about to create a small test project and see if I can reproduce this error. I wanted to do this after none of the methods that I used to fix the issue worked but I also wanted to see if there is a way to fix it without creating a new project as I have made some progress in my existing project.
@manugil I wanted to let you know that I have resolved the issue. I had to change a “Meta Quest Support” feature’s setting so that Internet access is not removed. I honestly had no clue about this setting option. I believe it is a security thing, but anyways, here is what I did:
Go to Project Setting → XR Plug-in Management → Open XR
Under Android tab, in the OpenXR Feature Groups. Select the gear symbol for “Meta Quest Support” feature row. This will open the settings editor for that feature
After doing this, <uses-permission android:name="android.permission.INTERNET" /> appeared in the AndroidManifest.xml of the decompiled build.apk and my app was able to successfully initiate a socket connection.
Thanks for such a detailed explanation on how to solve this issue, it will definitely help other users facing it. According to the release notes on the OpenXR Plugin, seems like “Force remove Internet Permission” is a relatively new option.
I still have this issue with version 2023.1.9f1. The option “Force Remove Internet” is re-enabled and removing the option and building again is not enough to include Internet access in the APK manifest. Instead I need to do a clean build to update the manifest file in the APK.
The next question is how can we programmatically remove the Meta Quest Support feature when unneeded for builds for the interim. The force remove internet toggle is reenabled, eg. after recompiling scripts, from the editor processor (super annoying).
Even more annoying is that support feature has internal fields, so we can’t simply set the field.
Is this a situation where we need to use a post gradle callback script and force the internet permission to be present?
I had this issue appear out of nowhere switching from unity 2022.3.9 to 2022.3.11 - I think it may be due to upgrading from Oculus XR Plugin 4.0.0 to 4.1.1. Unchecking the checkbox did not bring back the internet permission. I had to manually add the permission line to my custom manifest file.
Is this really seen as “resolved”? I think maybe I got this to work once, using a custom AndroidManifest and removing that option with “force disable Internet”, but it never fully worked and now I the webrequests consistently fail every time and Unity keeps reenabling that option.
Shouldnt the custom manifest solve this? I am trying to get gltfast to work on the Quest 3. Seems in 2022.3.11 I cannot even downgrade the plugin to 1.7.0, so I guess I might have to download an older version of Unity 2022.3 to get this to work?
Custom manifest does not solve this - manifests are merged together and modified by whatever build processors are included in the project. You could write a post gradle callback script to force include the internet permission as a last resort.
No it is not available. I’m pulling my hair out trying to find it. They have documentation posted for 1.9.1 but you can’t actually download or install a version 1.9 anywhere. Package manager only lets you get 1.8.2 or previous.
Unity when will 1.9.1 be available? I really need this fix so we can actually automate our build and it produces a working apk.