Please help, I have two separate projects both with the same issues after upgrading from 2019.4 LTS to 2020.3 LTS. When building I get the following gradle error:
CommandInvokationFailure: Gradle build failed.
D:\Unity\2020.3.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath āD:\Unity\2020.3.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jarā org.gradle.launcher.GradleMain ā-Dorg.gradle.jvmargs=-Xmx4096mā āassembleDebugā
stderr[
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ā:launcher:compileDebugJavaWithJavacā.
Could not resolve all task dependencies for configuration ā:launcher:debugCompileClasspathā.
Could not resolve project :unityLibrary.
Required by:
project :launcher
Unable to find a matching variant of project :unityLibrary:
Variant ādebugApiElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attribute:
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā and found incompatible value āApkā.
Other attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found compatible value ādebugā.
Found com.android.build.api.attributes.VariantAttr ādebugā but wasnāt required.
Required org.gradle.usage ājava-apiā and found compatible value ājava-apiā.
Variant ādebugReverseMetadataElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attribute:
Required org.gradle.usage ājava-apiā and found incompatible value āandroid-reverse-meta-dataā.
Other attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found compatible value ādebugā.
Found com.android.build.api.attributes.VariantAttr ādebugā but wasnāt required.
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā but no value provided.
Variant ādebugRuntimeElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attribute:
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā and found incompatible value āApkā.
Other attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found compatible value ādebugā.
Found com.android.build.api.attributes.VariantAttr ādebugā but wasnāt required.
Required org.gradle.usage ājava-apiā and found compatible value ājava-runtimeā.
Variant āreleaseApiElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found incompatible value āreleaseā.
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā and found incompatible value āApkā.
Other attributes:
Found com.android.build.api.attributes.VariantAttr āreleaseā but wasnāt required.
Required org.gradle.usage ājava-apiā and found compatible value ājava-apiā.
Variant āreleaseReverseMetadataElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found incompatible value āreleaseā.
Required org.gradle.usage ājava-apiā and found incompatible value āandroid-reverse-meta-dataā.
Other attributes:
Found com.android.build.api.attributes.VariantAttr āreleaseā but wasnāt required.
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā but no value provided.
Variant āreleaseRuntimeElementsā capability gradleOut:unityLibrary:unspecified:
Incompatible attributes:
Required com.android.build.api.attributes.BuildTypeAttr ādebugā and found incompatible value āreleaseā.
Required com.android.build.gradle.internal.dependency.AndroidTypeAttr āAarā and found incompatible value āApkā.
Other attributes:
Found com.android.build.api.attributes.VariantAttr āreleaseā but wasnāt required.
Required org.gradle.usage ājava-apiā and found compatible value ājava-runtimeā.
BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action
1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
Rethrow as BuildFailedException: Exception of type āUnityEditor.Build.BuildFailedExceptionā was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <0c3742f371b24679bcaa6fcc508d0cca>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Do you use custom gradle files, theyāre might be not compatible with 2020.
Hi Tomas,
No I donāt use custom gradle files. I just installed 2020.3 LTS through Unity Hub, then changed the projects Unity version to that. Let the upgrade process ādo itās stuffā, then tried building for android and instantly got a gradle error.
These are the publishing settings from my player settings:
I assume this means it uses whatever .gradle templates exist as default?
My External tools settings are:
Any ideas would be really great, I tried reverting to 2019.4 but get lots of script errors, which I assume was caused by the upgrade process so now I am stuck not being able to build my .apk.
It is worth noting that I have two android projects which have this issue and they were working in 2019.4 so itās not an isolated case.
Thanks
Try this - select Export Project
Export Project with your upgraded game with 2020.3
Create Empty project with 2020.3, export project
Compare gradle files between two exports, maybe it will help you spot an error
Hi, sorry I donāt see an option for export project other than exporting it as a package?
I also tried opening a brand new URP project from Unity Hub and trying to build for Android, same issue is happening. I also found a bug report yesterday which seemed slightly related. It is a shame this occurring in an LTS version. It is preventing me from testing recent changes to my app.
Please provide more information on the export project option.
Hereās the export project option
Thanks for this, I will give it a go but I am guessing that because Empty Project, URP Project and Oculus project I have still donāt build itās either a bug or something with my machine. I have another machine I can try just to see if there .gradle is different there.
Thanks for your help.
For future readers, I managed to get Unity 2020.3 building the same projects on another machine, which told me something was wrong with my local set up. I managed to find some rogue gradle folders inside C:\Users{Username}. I removed these folders, but the build still didnāt work. I then uninstalled all versions of Unity which I had installed in hub. Restarted my machine, re-installed only 2020.3 and the build began working again.
Not sure if the rogue gradle files were somehow the issue but at least the build is working now.
Thanks for the help Tomas1856. Your export idea helped me get a grasp on things.
2 Likes