SDK for Unity (PC, web) / How to set up application build for Android 11 on Unity 2019
  Back to Docs

SDK for Unity (PC, web)

How to set up application build for Android 11 on Unity 2019

To support Android 11 (API level 30), the package visibility <queries> element was added to some Android libraries. The <queries> element requires Gradle version 5.6.4 or later. It is recommended to use Gradle version 6.9.2 as this version is supported by Unity 2019, 2020, and 2021.

In Unity version 2020 and higher, Gradle version with Android 11 support is installed by default.

To install Gradle with Android 11 support, follow these steps:

  1. Download Gradle 6.9.2.
  2. Open your project in Unity Editor.
  3. In the main menu, go to Edit > Preferences (Windows) or Unity > Preferences (macOS).
  4. Go to External Tools > Android section.
  5. Uncheck the Gradle installed with Unity box.
  6. In the Gradle field, click Browse and select the folder with Gradle 6.9.2 files.
  1. In the main menu, go to Edit > Project Settings.
  2. Go to Player > Android tab.
  3. In the Publishing Settings > Build section, check the Custom Main Gradle Template, Custom Launcher Gradle Template, and Custom Gradle Properties Template boxes.
  4. Add the following line in the Assets/Plugins/Android/gradleTemplate.properties file:
Copy
Full screen
Small screen
android.useAndroidX=true
  1. Make the following changes in the Assets/Plugins/Android/mainTemplate.gradle and Assets/Plugins/Android/launcherTemplate.gradle files:
    1. Delete the following comment at the beginning of the file (may be missing):
Copy
Full screen
Small screen
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    1. Add the following lines in the beginning of the file:
Copy
Full screen
Small screen
buildscript {
repositories {
		google()
		jcenter()
	}
    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()
		jcenter()
		flatDir {
        dirs 'libs'
  		}
	}
}
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: September 15, 2023

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!