To support Android 11 (API level 30), the package visibility
<queries>
element was added to the ARCore SDK for Unity (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. Versions of Unity that do not support customization of Gradle are
unable to target Android 11 (API level 30) (targetSdkVersion 30
) directly from
a Unity build.
For more information see these articles:
- Unity's Gradle support
- Android's Configure Gradle Build
Unity 2019.3 and 2019.4
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.
Go to Project Settings > Player > Android tab > Publishing Settings > Build, and select both:
- Custom Main Gradle Template
- Custom Launcher Gradle Template.
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() 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' } } }
2019.1 and 2019.2
Go to Preferences > External Tools > Android > Gradle Installed with Unity. Clear the option, and specify a custom version of 5.6.4 or later. See Gradle build tool for downloads.
Go to Project Settings > Player > Android Tab > Publishing Settings > Build, and select Custom Gradle Template.
Edit the generated file
Assets/Plugins/Android/mainTemplate.gradle
, and set the dependencycom.android.tools.build:gradle
to 3.6.0 or later based on the Gradle version you use.buildscript { 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' } }
Unity 2018.4
Go to Build Settings > Android, and set Build System to Gradle to use the custom Gradle version.
Go to Preferences > External Tools > Android > Gradle Installed with Unity. Clear the option, and specify a custom version of 5.6.4 or later. See Gradle build tool for downloads.
Go to Project Settings > Player > Android tab > Publishing Settings > Build, and select Custom Gradle Template.
Edit the generated file
Assets/Plugins/Android/mainTemplate.gradle
, and set the dependencycom.android.tools.build:gradle
to 3.6.0 or later based on the Gradle version you use.buildscript { 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' } }
Unity 2018.3 or earlier, including 2017
Gradle customizations are not supported on these versions of Unity and are not compatible with the necessary changes to support Android 11 (API level 30).
The ARCore SDK for Unity strips the Android 11 (API level 30) support on those versions, so your app still works seamlessly on Android 10 (API level 29) and earlier.