A way to stop unity for adding unwanted permissions when building for android

I am requesting a switch or something to tell unity when it makes the manifest, to not include the Record_Audio and Microphone permissions. When creating an Oculus Quest app, and uploading it to the Oculus App store, it lists those permissions as not needed and fails to accept it. Anytime a routine references a Microphone, or Recording, Unity automatically adds those permissions to the android manifest. I have done a lot of searching, and to remove those permissions is very hard. This would make it much easier to get a Unity app on the Oculus App store.
Thanks

1 Like

How about removing the parts of your code referencing the microphone, or recording?

I guess that would work, but it is not my code that includes it. It is in the Oculus code. And removing that might work, but each time Oculus is updated, it would be back. That has to be a better way. How many people create games for Oculus Quest?

1 Like

Watch this video and you can see how hard it is to do.


There really should be a better way!

Come on people that create Quest 2 Games. Back me up!

I'll look into this issue. Thanks for bringing it up! We already explicitly remove the BLUETOOTH permission in this case, but it looks like there are other permissions we need to look at as well.

1 Like

Thanks so much.

Any update?

Did you know that you can use a custom AndroidManifest and other custom stuff?

No.

1 Like

https://docs.unity3d.com/Manual/android-manifest.html

https://docs.unity3d.com/Manual/overriding-android-manifest.html

Solved

We recently had a fix related in our OpenXR XR Plugin package: Meta/Oculus builds now don't include Bluetooth permissions in Android manifest by default when using Microphone class in script code. Fix will be included in our OpenXR SDK 1.7.0 release, which will be released very soon at the beginning of March.

1 Like

Will this also exclude the Microphone Permissions?

Ok, so basically there "is no fix" but there is a hack. After building your program, download Apktool, decompress the APK, modify de manifest, and recompress to apk. After that, you will need to use zipalign to align the apk. Then finally, sign the apk with apksigner. zipalign and apksigner are on the unity editor instalation SDK\build-tools\30.0.3\

I managed to publish my app yesterday with Oculus Integration 50 and Unity 2022.2.16f1.

You can add extra lines within the android manifest in Unity that removes permissions.
Take a look at the UPDATE 2021.04.08 section near the end of this article that provides an example.
https://skarredghost.com/2021/03/24/unity-unwanted-audio-permissions-app-lab/

1 Like

Thanks so much. I did not notice that the video had been updated. That worked GREAT!

long time after this question posted but still this problem may be annoying for someone!
I had a similar problem ,one plugin was adding some unwanted permissions and found an easy way to remove them,it may work in your case too.
A brief explaination:
Enable the custom Android Manifest option in player settings
Open the created android manifest file and add permissions you dont want with property of tools:node="remove" and it will override it! no decompile or any tricky method needed!
like this:
(add these tags before starting of application tag in manifest file)

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

i explained it on another topic too check it out if you need

hope it helps

4 Likes

What condition removes this?

So I can’t get BLUETOOTH to remove with line

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

And yes the manifest is including tools

xmlns:tools="http://schemas.android.com/tools"

This is preventing publishing

try this:

<uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" tools:node="remove" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:node="remove" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" tools:node="remove" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" tools:node="remove" />

if it still didn’t fix the problem,I recommend you to check your code to see which component or plugin needs Bluetooth ,if didn’t find anything check manifest merger report and see what exactly is adding that permission(because hopefuly the source of it will be mentioned there) , and if that didn’t help too,you may need to try the hard way,something like decompiling and editing manifest and resigning.(check this)

We've a solution for these issues in a upcoming version of XR Management package, which will allow to clear the Android permissions, so custom code can add or remove permissions as they see fit.

As another option, starting in Unity 2023 there's an API for editing the manifest at build time: https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Android.AndroidProjectFilesModifier.html