Google is committed to advancing racial equity for Black communities. See how.

Build for Android 11 with Unity

To support Android 11 (API level 30), the 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.

Unity gradle support

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

For more information see these articles:

Unity 2021 and later

All versions of Unity 2021 support targeting Android 11. Refer to Unity's 2021 Gradle for Android 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 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. Go to Preferences > External Tools > Android > Gradle, and set the custom Gradle to Gradle 5.6.4 or later. See Gradle build tool for downloads.

    A screenshot of the External Tools, Android pane showing a manually
specified Gradle path.

  2. Go to Project Settings > Player > Android tab > 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

  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'
          }
       }
    }