Gradle build failed

Include the following details (edit as applicable):

  • Issue category: ARDK Documentation
  • Device type & OS version: Android
  • Host machine & OS version: Windows
  • Issue Environment : Unity
  • Xcode version:
  • ARDK version: 2.3.0
  • Unity version: Unity 2020.3.2f1

Description of the issue:
Sorry a newbie problem, I followed the basic tutorial and when I set up and build for Android, it failed.
It failed after I did the “Building for Android API level 31 with OpenCL” part.

Configure project :launcher
WARNING:: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
You will no longer be able to disable R8
WARNING:: Using flatDirs should be avoided because it doesn’t support any meta-data formats.
Currently detected usages:

  • repository flatDir used in: root project ‘gradleOut’, project ‘:launcher’, project ‘:unityLibrary’
    WARNING:: Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.
    This repository is deprecated and it will be shut down in the future.

Currently detected usages in: root project ‘gradleOut’, project ‘:launcher’, project ‘:unityLibrary’
WARNING:: The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.0.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove “buildToolsVersion ‘28.0.3’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING:: The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.0.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove “buildToolsVersion ‘28.0.3’” from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Checking the license for package Android SDK Build-Tools 30.0.2 in C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\licenses
Warning: License for package Android SDK Build-Tools 30.0.2 not accepted.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ‘:launcher:compileReleaseJavaWithJavac’.

Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another

Using Android SDK: C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ‘:launcher:compileReleaseJavaWithJavac’.

Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another

Using Android SDK: C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Build completed with a result of ‘Failed’ in 29 seconds (29209 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Sorry I’m new :face_with_spiral_eyes:

Tried updating Unity? That version is really old

In the basics tutorial it wrote “Unity version 2020.3.2f1 (Lightship currently supports Unity version 2020.3.2f1)” for the requirement… so i was afraid to get any other version. Any version that is good?

Just get the latest 2020 LTS
2021 LTS also is supported

Installed 2021 LTS and redo the basics tutorial, and it worked! Thank you.

I’m used 2021.3.12 version Still had same errors.

After I switched to 2021.3.11f1 (LTS), it works for me. Your version is not too different, not sure why.

Maybe start new project and try again. Can be a cache thing

i have same question.
i try to use this version (2021.3.11f1 ) but still get wrong
i had tried many editor version and i had tried to change the gradle version but still not work.
I had tried this : Building ARDK Apps for Android — Niantic Lightship Augmented Reality Developer Kit release-2.3 documentation
And no effect

For Unity 2020 and 2021 the LTS versions are the recommended builds. Lightship 2.3 included a Gradle update for those versions and it might not be supported in the other downloads

I succeeded finally!
I used Unity 2020.3.41f1 (LTS) and change the gradle version from the default (6.1.1) to version 7.5.1
(Because my smartphone’s OS version is Android 11)

I set the Android Min API Level to Android 11 (Level 30)
And keep Target API Level default (Automatic (highest installed )).

The steps for changing gradle version have followed this tutorial
https://lightship.dev/docs/ardk/ardk_fundamentals/building_android.html#building-for-android-11-api-level-30-and-higher

and this.
https://lightship.dev/docs/ardk/ardk_fundamentals/building_android.html#building-for-android-api-level-31-with-opencl

Finally, I Change the Unity editor to 2020.3.41f1 (LTS) version and it worked.