Gradle build error related to environmental variables in Unity

I’m using Unity 2021.3.16f1 and when building for android I get gradle build errors like this:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':launcher:debugRuntimeClasspath'.
   > Could not find androidx.startup:startup-runtime:1.1.1..
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/androidx/startup/startup-runtime/1.1.1./startup-runtime-1.1.1..pom
       - https://jcenter.bintray.com/androidx/startup/startup-runtime/1.1.1./startup-runtime-1.1.1..pom
.
.
.

In the complete log unity prints out the environmental variabels and the path for the $PATH variable is wrong and is pointing out the an older version of Unity:

PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Unity/Hub/Editor/2019.4.13f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Unity/Hub/Editor/2021.3.9f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools

Do I need to remove the redundant paths from this string?

Is this what it’s causing the gradle build error?

Here’s the complete log:
Gradle Build Failed

>Solution :

The error means Gradle could not resolve:

androidx.startup:startup-runtime:1.1.1.

note the the trailing . in the version: 1.1.1.

Change this to 1.1.1 and Gradle should be able to find the dependency and continue the build.

Leave a Reply