Skip to content

Update Android Manifest

Denis edited this page Jun 9, 2022 · 6 revisions

⚡ Before you start
Make sure you have correctly Include Android.


AndroidManifest template

If you do not find the manifest file Plugins/Android/AndroidManifest.xml, you can take it from the example.
Or Unity 2019.3+ makes it possible to activate in Player Settings > Publishing Settings > Build > Custom Main Manifest checkmark.

Update for Android 12

If your app targets Android 12, then you must explicitly declare the android:exported attribute. For all changes in Android 12, see Behavior changes in Android 12
Add the android:exported="true" attribute to the <activity> tag to Assets/Plugins/Android/AndroidManifest.xml:

<application ...>
  <activity android:name="com.unity3d.player.UnityPlayerActivity"
            android:theme="@style/UnityThemeSelector"
            android:exported="true">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
     <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
   </activity>
</application>

Optional permissions

Add the optional permissions to your Assets/Plugins/Android/AndroidManifest.xml file inside the <manifest> tag but outside the <application> tag.
VIBRATE permission is used for certain ads that vibrate during play. This is a normal level permission, so this permission just needs to be defined in the manifest to enable this ad feature.

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

ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permissions is not a mandatory permission, however, including it will enable accurate ad targeting.

<manifest>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <!-- OR -->
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

WRITE_EXTERNAL_STORAGE permission is used for certain ads that allow the user to save a screenshot to their phone. Note that with this permission on devices running Android 6.0 (API 23) or higher, this permission must be requested from the user. See Requesting Permissions for more details.

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

Included permissions in SDK

Sometimes permissions are included in the partner SDK’s internal AndroidManifest.
To remove a specific embedded permission (for example, ACCESS_COARSE_LOCATION), add the following tag to your top level AndroidManifest during integration:

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

What’s Next?

Clone this wiki locally