Sirop4ik
Sirop4ik

Reputation: 5263

How to add permissions to Unity android application?

In native android application if I need to declare that my application is going to use any permissions first of all I need to add them to AndroidManifest.xml file, like here

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.co.ar">

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

...

And this way I can just open application settings on the phone and see what permissions this application is using.

In unity I don't see a way to declare permissions that application is going to use. I found out according to this documentation

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

There is LibraryManifest.xml that responsible for permissions, I found this file and add there permissions I need, but because of this file is generated so every time I make new build it rewrites.

Upvotes: 1

Views: 8777

Answers (2)

Liena
Liena

Reputation: 131

Player Settings -> Tab (Android) -> Publishing Settings -> Check Custom Main Manifest -> Edit "AndroidManifest.xml" in Assets/Plugins/Android

Upvotes: 6

thunderkill
thunderkill

Reputation: 146

There is LibraryManifest.xml that responsible for permissions, I found this file and add there permissions I need, but because of this file is generated so every time I make new build it rewrites.

There by the way an asset that can do this android permissions

I hope you find this useful

Upvotes: 0

Related Questions