Como configurar a compilação do aplicativo para Android 11 no 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:
- Download Gradle 6.9.2.
- Open your project in Unity Editor.
- In the main menu, go to
Edit > Preferences (Windows) orUnity > Preferences (macOS). - Go to
External Tools > Android section. - Uncheck the
Gradle installed with Unity box. - In the
Gradle field, clickBrowse and select the folder with Gradle 6.9.2 files.
- In the main menu, go to
Edit > Project Settings . - Go to
Player > Android tab. - In the
Publishing Settings > Build section, check theCustom Main Gradle Template ,Custom Launcher Gradle Template , andCustom Gradle Properties Template boxes. - Add the following line in the
Assets/Plugins/Android/gradleTemplate.properties
file:
Copy
- groovy
android.useAndroidX=true
- Make the following changes in the
Assets/Plugins/Android/mainTemplate.gradle
andAssets/Plugins/Android/launcherTemplate.gradle
files:- Delete the following comment at the beginning of the file (may be missing):
Copy
- groovy
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
- Add the following lines in the beginning of the file:
Copy
- groovy
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'
}
}
}
Este artigo foi útil?
Obrigado pelo seu feedback!
Avaliaremos sua mensagem e a usaremos para melhorar sua experiência.Encontrou um erro de texto ou digitação? Selecione o texto e pressione Ctrl+Enter.