APK stopps working in quest VR when activating manifest becuase i need ot remove READ_PHONE_STATE

Dear XR Community,
Dear Unity Team

after grinding through many posts with similar issues i found out that when uploading a APK to METAS Store for quest there seems to be Permissions that are not allowed in the manifest (when using the build out of the box)

Official message meta dev:

The upload could not be completed because your application contains the following Android permissions that are not supported:
android.permission.READ_PHONE_STATE,
Please remove the following permissions and upload your application binary again.

I have then activated the Manifest checkbox and tried to add this line:

<uses-permission tools:node="remove"android:name="android.permission.READ_PHONE_STATE"/>

this is the manifest that appears in:

Assets/Plugins/Android/AndroidManifest.xml

However, the moment I do this and recompile my APK, my App does no longer work on meta quest, it is not starting in VR mode and I have to revert to the last revision before clicking the manifest button to get it ever working again :upside_down_face:

For your quick help we thank you @unity

I think it was fixed here - Unity Issue Tracker - [Android] With the latest Unity 6 editor, default APK permissions are not being set correctly if you have XR Plugin Mgmt package, you might want to update it.

i will try a packet update first, thanks for the hint!
Do i wonder why unity 6000.2 wiuold have old packets installed :upside_down_face:

If I recall correctly, this is because some gradle didn’t have minSdkLevel specified, which as a side effect caused READ_PHONE_STATE permission to be added, in other words if updating packing won’t work, export gradle project and check all build.gradle files and see if any of them don’t have minSdkLevel set.

Thanks @Tomas1856 i see if i can handle this, is there a official tutorial from unity how to do that?
We are using VIVOX and unity Multiplayer Services for it, anything special i need to concider?

Checking gradle files in exported project? No, there’s not tutorial for this, just use common sense.

I am not familiar myself with those services, but haven’t heard that anything needs to be tweaked there.

The error persists after updating the XR plugin Mgmt Package update.
Attempting now to export Gradle Files.

This is a very work intensive step, that would be great if fixed in unity 6000.2.

as it seems it has been fixed before: Unity Issue Tracker - [Android] With the latest Unity 6 editor, default APK permissions are not being set correctly

Unfortunately, ‘common sense’ doesn’t resolve the issue in this case, as it appears to be a reproducible Unity bug. I would appreciate more specific guidance how to fix this after the export into Android Studio.
For your effort, i thank you in advance.

I have now the build.gradle files opened i found, can anyone tell me how i could fix the problem?

in what of all the manifest do i have to edit or mention the wrongly added permission?

Gradle properties says:

unity.minSdkVersion=24
unity.targetSdkVersion=34
unity.compileSdkVersion=34

however in all files android studio marks this as deprecated:

android {
    namespace "com.unity3d.player"
    ndkPath "C:/Program Files/Unity/Hub/Editor/6000.2.6f2/Editor/Data/PlaybackEngines/AndroidPlayer/NDK"
    ndkVersion "27.2.12479018"
    compileSdk 34 <----- deprecated

build.gradle

  • build.gradle (Project: export)
    Show nothing about SDK min versions
  • build.gradle (Module: launcher)
    defaultConfig {
        applicationId "----cant share----"
        versionName ".511"
        minSdk 24
        targetSdk 34
        versionCode 1

        ndk {
            abiFilters "arm64-v8a"
            debugSymbolLevel "none"
        }
    }
  • build.gradle (Module: unityLibrary)
    defaultConfig {
        consumerProguardFiles "proguard-unity.txt"
        minSdk 24
        targetSdk 34

        ndk {
            abiFilters "arm64-v8a"
            debugSymbolLevel "none"
        }
    }
  • build.gradle (Module: unityLibrary:xrmanifest.androidlib)
    namespace "com.UnityTechnologies.XR.Manifest"
    compileSdk 34
    buildToolsVersion = "34.0.0"

    defaultConfig {
        minSdk 24
        targetSdk 34
    }

The manifest from launcher:

<?xml version="1.0" encoding="utf-8"?>
<manifest android:installLocation="preferExternal" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
  <application android:icon="@mipmap/app_icon" android:label="@string/app_name" />
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
</manifest>

The Library Manifest : library/xrmanifest.androidlib/manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.UnityTechnologies.XR.Manifest">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerGameActivity" android:exported="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|eureka|quest3s" />
  </application>
  <uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
  <uses-feature android:name="oculus.software.eye_tracking" android:required="true" />
  <uses-permission android:name="com.oculus.permission.EYE_TRACKING" />
</manifest>

and the unity library/manifest/manifests

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
  <uses-feature android:glEsVersion="0x00030000" />
  <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
  <uses-feature android:name="android.hardware.camera" android:required="false" />
  <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
  <uses-feature android:name="android.hardware.camera.front" android:required="false" />
  <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:appCategory="game" android:enableOnBackInvokedCallback="true" android:extractNativeLibs="true">
    <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.render-outside-safearea" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
    <meta-data android:name="unity.auto-report-fully-drawn" android:value="true" />
    <meta-data android:name="unity.strip-engine-code" android:value="true" />
    <meta-data android:name="unity.auto-set-game-state" android:value="true" />
    <activity android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:enabled="true" android:exported="true" android:hardwareAccelerated="false" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerGameActivity" android:resizeableActivity="true" android:screenOrientation="fullUser" android:theme="@style/BaseUnityGameActivityTheme">
      <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="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.app.lib_name" android:value="game" />
      <meta-data android:name="WindowManagerPreference:FreeformWindowSize" android:value="@string/FreeformWindowSize_maximize" />
      <meta-data android:name="WindowManagerPreference:FreeformWindowOrientation" android:value="@string/FreeformWindowOrientation_landscape" />
      <meta-data android:name="notch_support" android:value="true" />
      <layout android:minHeight="300px" android:minWidth="400px" />
      <intent-filter xmlns:android="http://schemas.android.com/apk/res/android">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="unitydl" android:host="com.unityplayeraccounts.489e4636-792f-424e-99bc-b948efa12f6e" />
      </intent-filter>
    </activity>
  </application>
</manifest>

Looks okay, hmph.

Did you try drag & droping apk in Android Studio, you can then inspect manifest file, do you READ_PHONE_STATE there too?

i Do that and get back, thanks for the tip.

Its in the manifest, when i open the APK

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName=".511"
    android:installLocation="2"
    android:compileSdkVersion="34"
    android:compileSdkVersionCodename="14"
    package="--cannotshare---"
    platformBuildVersionCode="34"
    platformBuildVersionName="14">

    <uses-sdk
        android:minSdkVersion="24"
        android:targetSdkVersion="34" />

    <supports-screens
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true" />

    <uses-permission
        android:name="android.permission.INTERNET" />

    <uses-permission
        android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission
        android:name="android.permission.CAMERA" />

    <uses-permission
        android:name="android.permission.RECORD_AUDIO" />

    <uses-permission
        android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

    <uses-feature
        android:glEsVersion="0x30000" />

    <uses-feature
        android:name="android.hardware.vulkan.version"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.microphone"
        android:required="true" />

    <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" />

    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission
        android:name="android.permission.BLUETOOTH_CONNECT" />

    <uses-permission
        android:name="android.permission.BLUETOOTH" />

    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission
        android:name="android.permission.READ_PHONE_STATE" />

    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <uses-permission
        android:name="org.khronos.openxr.permission.OPENXR" />

    <uses-permission
        android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" />

    <queries>

        <provider
            android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" />

        <intent>

            <action
                android:name="org.khronos.openxr.OpenXRRuntimeService" />
        </intent>

        <intent>

            <action
                android:name="org.khronos.openxr.OpenXRApiLayerService" />
        </intent>
    </queries>

    <uses-feature
        android:name="android.hardware.vr.headtracking"
        android:required="true"
        android:version="1" />

    <uses-feature
        android:name="oculus.software.eye_tracking"
        android:required="true" />

    <uses-permission
        android:name="com.oculus.permission.EYE_TRACKING" />

    <permission
        android:name="--cannotshare---"
        android:protectionLevel="0x2" />

    <uses-permission
        android:name="--cannotshare---" />

    <application
        android:label="@ref/0x7f0d0021"
        android:icon="@ref/0x7f0c0000"
        android:extractNativeLibs="true"
        android:appCategory="0"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:enableOnBackInvokedCallback="true">

        <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.render-outside-safearea"
            android:value="true" />

        <meta-data
            android:name="notch.config"
            android:value="portrait|landscape" />

        <meta-data
            android:name="unity.auto-report-fully-drawn"
            android:value="true" />

        <meta-data
            android:name="unity.strip-engine-code"
            android:value="true" />

        <meta-data
            android:name="unity.auto-set-game-state"
            android:value="true" />

        <activity
            android:theme="@ref/0x7f0e00a1"
            android:name="com.unity3d.player.UnityPlayerGameActivity"
            android:enabled="true"
            android:exported="true"
            android:launchMode="2"
            android:screenOrientation="13"
            android:configChanges="0x40003fff"
            android:hardwareAccelerated="false"
            android:resizeableActivity="true">

            <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="unityplayer.UnityActivity"
                android:value="true" />

            <meta-data
                android:name="android.app.lib_name"
                android:value="game" />

            <meta-data
                android:name="WindowManagerPreference:FreeformWindowSize"
                android:value="@ref/0x7f0d0002" />

            <meta-data
                android:name="WindowManagerPreference:FreeformWindowOrientation"
                android:value="@ref/0x7f0d0000" />

            <meta-data
                android:name="notch_support"
                android:value="true" />

            <layout
                android:minWidth="400px"
                android:minHeight="300px" />

            <intent-filter>

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.DEFAULT" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="unitydl"
                    android:host="com.unityplayeraccounts.489e4636-792f-424e-99bc-b948efa12f6e" />
            </intent-filter>

            <meta-data
                android:name="com.oculus.vr.focusaware"
                android:value="true" />
        </activity>

        <meta-data
            android:name="com.oculus.supportedDevices"
            android:value="quest|quest2|cambria|eureka|quest3s" />

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:exported="false"
            android:authorities="ch.VRFX.VRCoach.androidx-startup">

            <meta-data
                android:name="androidx.emoji2.text.EmojiCompatInitializer"
                android:value="androidx.startup" />

            <meta-data
                android:name="androidx.lifecycle.ProcessLifecycleInitializer"
                android:value="androidx.startup" />
        </provider>
    </application>
</manifest>

At this point, I think it’s better for you to submit a bug with repro project attached.

Yes i have reported the Bug a few Days ago, had no answer yet.

Do you have case number ?

Case Number: IN-126376

Hey, I took a look a bit, and it seems this issue comes from Vivox, I don’t think it was reported before, so it might take a while until this is fixed.

How did I debug? (might help somebody in the future)

  • Export gradle project from Unity
  • In gradle.properties, add line
android.enableManifestMergeLogs=true
  • Produce build
  • launcher\build\outputs\logs\manifest-merger-debug-report.txt will be created

In this case it contains

uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
IMPLIED from launcher\src\main\AndroidManifest.xml:2:1-5:12 reason: com.vivox.vivoxnative has a targetSdkVersion < 4
uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from auncher\src\main\AndroidManifest.xml:2:1-5:12 reason: com.vivox.vivoxnative has a targetSdkVersion < 4
uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from launcher\src\main\AndroidManifest.xml:2:1-5:12 reason: com.vivox.vivoxnative requested WRITE_EXTERNAL_STORAGE

Basically AndroidManifest.xml in VivoxNative.aar doesn’t declared targetSdk, thus gradle assumes lowest target sdk, which implicitly adds READ_PHONE_STATE permission.

I see that the fix was made in Vivox repository, so probably next Vivox package release will contain the fix.

Thanks @Tomas1856 we now can’t continue and everything is on a halt.
We should have pushed the ap to the META Store Days ago.

I updated the VIVOX Package to 16.8.0 But the permission is still being set

   <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission
        android:name="android.permission.READ_PHONE_STATE" />

    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE" />

is it possible to recieve any eta on this?
Is having a Unity Pro license helping to get faster Support?

Our Production is now on halt, until we can start uploading to META Plattform.

I have no opened a supprt request on the VIVOX Bug:

https://support.unity.com/hc/en-us/requests/2539058

Hi pachermann,

We did fix this issue on our side, a hotfix is will be released late next week or early the week after.

Dear @Taleb_Souli thank you so much for this quick fix!
How can i see when the packet manager gets this update?

Kindest regards
Pascal