Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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

Discussion in 'Android' started by DaNueromancer, Jul 29, 2023.

  1. DaNueromancer

    DaNueromancer

    Joined:
    Mar 28, 2023
    Posts:
    3
    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:

    1) 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.

    2) 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.

    3) 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"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="0.1" android:installLocation="auto" android:compileSdkVersion="32" android:compileSdkVersionCodename="12" package="com.DefaultCompany.ScannerDemo" platformBuildVersionCode="32" platformBuildVersionName="12">
    <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32"/>
    <supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true"/>
    <uses-permission android:name="com.oculus.permission.HAND_TRACKING"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1"/>
    <uses-feature android:name="oculus.software.handtracking" android:required="false"/>
    <uses-feature android:name="android.hardware.vulkan.version" android:required="true"/>
    <uses-feature android:name="android.hardware.microphone" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/>
    <application android:label="@String/app_name" android:icon="@Mipmap/app_icon" android:allowBackup="false" android:extractNativeLibs="true" android:networkSecurityConfig="@XML/network_sec_config">
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false"/>
    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
    <meta-data android:name="com.oculus.handtracking.frequency" android:value="HIGH"/>
    <meta-data android:name="com.oculus.handtracking.version" android:value="V2.0"/>
    <meta-data android:name="unity.splash-mode" android:value="0"/>
    <meta-data android:name="unity.splash-enable" android:value="true"/>
    <meta-data android:name="unity.launch-fullscreen" android:value="true"/>
    <meta-data android:name="unity.allow-resizable-window" android:value="false"/>
    <meta-data android:name="notch.config" android:value="portrait|landscape"/>
    <meta-data android:name="unity.auto-report-fully-drawn" android:value="true"/>
    <activity android:theme="@StyLe/Theme.Black.NoTitleBar.Fullscreen" android:name="com.unity3d.player.UnityPlayerActivity" android:exported="true" android:excludeFromRecents="true" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
    <intent-filter>
    <category android:name="android.intent.category.LAUNCHER"/>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="com.oculus.intent.category.VR"/>
    </intent-filter>
    <meta-data android:name="notch_support" android:value="true"/>
    <meta-data android:name="com.oculus.vr.focusaware" android:value="true"/>
    </activity>
    <meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2|cambria"/>
    </application>
    </manifest>

    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.

    Thanks.
     
    Last edited: Jul 29, 2023
  2. manugil

    manugil

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    94
    Hey @DaNueromancer,

    Do you mind sharing your custom manifest in
    Assets/Plugins/Android\AndroidManifest.xml
    here?

    Thank you! :)
     
    DaNueromancer likes this.
  3. DaNueromancer

    DaNueromancer

    Joined:
    Mar 28, 2023
    Posts:
    3
    Thanks for your response. My custom manifest is below:
    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8" standalone="no"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
    3.   <uses-permission android:name="com.oculus.permission.HAND_TRACKING" />
    4.   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    5.   <uses-permission android:name="android.permission.INTERNET" />
    6.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    7.   <application android:label="@string/app_name" android:icon="@mipmap/app_icon" android:allowBackup="false">
    8.     <activity android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:excludeFromRecents="true" android:exported="true">
    9.       <intent-filter>
    10.         <action android:name="android.intent.action.MAIN" />
    11.         <category android:name="android.intent.category.LAUNCHER" />
    12.       </intent-filter>
    13.     </activity>
    14.     <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
    15.     <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
    16.     <meta-data android:name="com.oculus.handtracking.frequency" android:value="HIGH" />
    17.     <meta-data android:name="com.oculus.handtracking.version" android:value="V2.0" />
    18.   </application>
    19.   <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
    20.   <uses-feature android:name="oculus.software.handtracking" android:required="false" />
    21. </manifest>
    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.
     
  4. DaNueromancer

    DaNueromancer

    Joined:
    Mar 28, 2023
    Posts:
    3
    @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:

    1) Go to Project Setting -> XR Plug-in Management -> Open XR

    2) 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

    Meta Quest Support setting.jpg

    3) In the settings editor, under "Feature Settings" section there is a sub-section called "Manifest Settings"

    4) Uncheck the "Force Remove Internet" option under the "Manifest Setting" sub-section

    Meta Quest Support setting editor.jpg

    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.
     
    Last edited: Aug 1, 2023
    wadidi, Unsui, ceitel and 2 others like this.
  5. manugil

    manugil

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    94
    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.
     
    DaNueromancer likes this.
  6. Archtica

    Archtica

    Joined:
    Mar 23, 2018
    Posts:
    48
    Thank you so much @DaNueromance, this helped me too! Impossible to know.
     
    ceitel and DaNueromancer like this.
  7. abreu9999

    abreu9999

    Joined:
    Jun 14, 2016
    Posts:
    1
    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.
     
    T3ddyTheGiant and MikleRe like this.
  8. T3ddyTheGiant

    T3ddyTheGiant

    Joined:
    Aug 1, 2018
    Posts:
    11
    Okay so this is such a gotcha moment...

    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?
     
  9. semateos

    semateos

    Joined:
    May 11, 2016
    Posts:
    18
    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.
     
  10. semateos

    semateos

    Joined:
    May 11, 2016
    Posts:
    18
    Oh wait, it's still being removed! The checkbox is unchecked! What fresh hell is this?
     
  11. semateos

    semateos

    Joined:
    May 11, 2016
    Posts:
    18
    Oh, and the checkbox comes back checked after restarting unity.
     
  12. T3ddyTheGiant

    T3ddyTheGiant

    Joined:
    Aug 1, 2018
    Posts:
    11
    Best option is to just downgrade OpenXR to v1.7.0 for the interim
     
  13. semateos

    semateos

    Joined:
    May 11, 2016
    Posts:
    18
    manugil likes this.
  14. kblood

    kblood

    Joined:
    Jun 20, 2012
    Posts:
    92
    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?
     
  15. T3ddyTheGiant

    T3ddyTheGiant

    Joined:
    Aug 1, 2018
    Posts:
    11
    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.
     
  16. manugil

    manugil

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    94
    According to OXRB-252, this issue has now been fixed for OpenXR 1.9.1.
     
    T3ddyTheGiant and Emsoba_ like this.
  17. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,688
    And what is the prospective release date for 1.9.1 @manugil , because the only available version on 2022.3 currently is 1.8.2?
     
    taimex likes this.
  18. steve-synth

    steve-synth

    Joined:
    Aug 22, 2023
    Posts:
    1
  19. JDH

    JDH

    Joined:
    Jul 1, 2013
    Posts:
    1
    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.
     
    AndreaDAn likes this.
  20. MasyMo

    MasyMo

    Joined:
    Mar 26, 2022
    Posts:
    4
    @JDH: I case you havnt already fixed it. Try this is the package Manger -> upload_2023-11-21_12-58-20.png
     

    Attached Files:

    cliv3dev and BroccoliGamesCZ like this.
  21. nobatgeldi

    nobatgeldi

    Joined:
    Feb 6, 2016
    Posts:
    2
  22. Geist2501

    Geist2501

    Joined:
    Jun 29, 2019
    Posts:
    25
    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.
     
  23. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    49

    I have the same problem with Pico 4 ... did you work around it somehow?
     
  24. Unsui

    Unsui

    Joined:
    Oct 10, 2017
    Posts:
    4
    Big Thanks man! After 3 weeks of hard time and when I gave up god gives me you )
     
    DaNueromancer likes this.
  25. kade_c

    kade_c

    Joined:
    Feb 6, 2023
    Posts:
    1
    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
     
  26. Kadarch

    Kadarch

    Joined:
    Jul 27, 2023
    Posts:
    1
    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 <uses-permission android:name="android.permission.INTERNET" /> as it was stated at the top of this thread?
     
  27. RockyH

    RockyH

    Joined:
    Feb 24, 2014
    Posts:
    8
    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.
     
  28. vzabladowski

    vzabladowski

    Joined:
    Nov 12, 2020
    Posts:
    1
    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
    upload_2024-5-15_20-19-18.png
    Hope it will helps some of you.
     
    wadidi likes this.
  29. SwingTechOIiver

    SwingTechOIiver

    Joined:
    Jan 11, 2024
    Posts:
    3
    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.
    Code (CSharp):
    1. private IEnumerator TestNetworkConnectivity()
    2. {
    3.     UnityWebRequest request = UnityWebRequest.Get("https://www.google.com");
    4.     yield return request.SendWebRequest();
    5.  
    6.     if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
    7.     {
    8.         Debug.LogError("OLILOG Network Test Error: " + request.error);
    9.     }
    10.     else
    11.     {
    12.         Debug.Log("OLILOG Network Test Success: " + request.downloadHandler.text);
    13.     }
    14. }
     
  30. aSyry

    aSyry

    Joined:
    Sep 1, 2023
    Posts:
    1
    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.
     
  31. saadjumani

    saadjumani

    Joined:
    Apr 12, 2016
    Posts:
    18
    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.
     
  32. ChidambaramS

    ChidambaramS

    Joined:
    Mar 30, 2023
    Posts:
    2