To support Android 11 (API level 30), the [package visibility](https://developer.android.com/training/package-visibility)
`<queries>` element was added to ARCore Extensions for AR Foundation (1.19 or later).
When using these versions of ARCore, the `<queries>` element requires Gradle version
5.6.4 or later.

In most cases, using the ***Android Gradle plugin* version 3.6.0** is
sufficient. To confirm compatibility between the Android Gradle plugin and the
Gradle version you are using, consult the Android Gradle plugin
[compatibility table](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle).

## Unity gradle support

Instructions for supported versions of Unity are listed in the following
sections.

For more information see these articles:

- Unity's [Gradle support](https://docs.unity3d.com/Manual/android-gradle-overview.html)
- Android's [Configure Gradle Build](https://developer.android.com/studio/build)

## Unity 2021 and later

All versions of Unity 2021 support targeting Android 11. Refer to Unity's 2021
[Gradle for Android](https://docs.unity3d.com/2021.2/Documentation/Manual/android-gradle-overview.html)
documentation for detailed version information. To summarize:

- Unity 2021.1 up to and including 2021.1.15f1 ship with Gradle 5.6.4 or later
  (and Gradle plugin 3.6.0 or later). No action is required.

- Unity 2021.1.16f1 and later ship with Gradle 6.1.1 or later (and
  Gradle plugin 4.0.1 or later). No action is required.

## Unity 2020

All versions of Unity 2020 support targeting Android 11. Refer to Unity's 2020
[Gradle for Android](https://docs.unity3d.com/2020.3/Documentation/Manual/android-gradle-overview.html)
documentation for detailed version information. To summarize:

- Unity 2020.1, 2020.2 and 2020.3 up to and including 2020.3.14f1 ship with
  Gradle 5.6.4 or later (and Gradle plugin 3.6.0 or later).
  No action is required.

- Unity 2020.3.15f1 and later ship with Gradle 6.1.1 or later (and
  Gradle plugin 4.0.1 or later). No action is required.

## Unity 2019.4

1. In Unity, open **[Unity Preferences](https://docs.unity3d.com/2019.4/Documentation/Manual/Preferences.html) \> [External Tools](https://docs.unity3d.com/2019.4/Documentation/Manual/Preferences.html#external-tools)** and set the custom
   **Gradle** to Gradle **5.6.4** or later. See
   [Gradle build tool](https://gradle.org/releases/) for downloads.

   ![A screenshot of the External Tools, Android pane showing a manually
   specified Gradle path.](https://developers.google.com/static/ar/develop/unity-arf/images/android11-set-gradle-564_x2.png)
2. Go to **Project Settings \> Player \> Android \> Publishing Settings \>
   Build**, and select both:

   1. **Custom Main Gradle Template**
   2. **Custom Launcher Gradle Template**.

   ![A screenshot showing the Publishing Settings, Build pane with both Gradle
   Template options selected](https://developers.google.com/static/ar/develop/unity-arf/images/android11-set-gradle-templates_x2.png)
3. Apply the following changes to both generated files:

   - `Assets/Plugins/Android/mainTemplate.gradle`
   - `Assets/Plugins/Android/launcherTemplate.gradle`

   If present, remove the following comment at the top of the file:

       // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

   Insert the following lines at the top of the file:

       buildscript {
           repositories {
               google()
               mavenCentral()
           }
           dependencies {
               // Must be Android Gradle Plugin 3.6.0 or later. For a list of
               // compatible Gradle versions refer to:
               // https://developer.android.com/studio/releases/gradle-plugin
               classpath 'com.android.tools.build:gradle:3.6.0'
           }
       }

       allprojects {
          repositories {
             google()
             mavenCentral()
             flatDir {
               dirs 'libs'
             }
          }
       }