添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I can’t build a project, unity can’t get access to some servers and it doesn’t matter if I use a proxy or not. I can’t log in to the server itself either, I get the error 403 access denied.

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Gradle\gradle-4.0.1\lib\gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “bundleRelease”

stderr[

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:launcher’.
  • Could not resolve all files for configuration ‘:launcher:classpath’.
    Could not resolve com.android.tools.build:gradle:4.0.1.
    Required by:
    project :launcher
    Could not resolve com.android.tools.build:gradle:4.0.1.
    Could not get resource ‘ https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom ’.
    Could not GET ‘ https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom ’. Received status code 403 from server: Forbidden

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

    BUILD FAILED in 9s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    stdout[
    Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
    Parallel execution is an incubating feature.
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Команда+WaitingForProcessToExit waitingForProcessToExit, System.String ErrorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Команда.Run (System.Строковая команда, Система.Строковые арги, Система.String workingdir, UnityEditor.Android.Команда+WaitingForProcessToExit waitingForProcessToExit, System.String ErrorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidJavaTools.Рунджава (Система.Строковые арги, Система.Строка workingdir, System.Действие ’ 1[T] прогресс, Система.Строковая ошибка) (при <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.ГрэдлеВраппер.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.Строка workingdir, System.Строковая задача, Система.Действие 1[T] прогресс) (at <25e82ad8f640476c8ff807f13e25668c>:0) Rethrow as GradleInvokationException: Ошибка сборки Gradle UnityEditor.Android.ГрэдлеВраппер.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.Строка workingdir, System.Строковая задача, Система.Действие 1[T] прогресс) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Постпроцессор.Задачи.BuildGradleProject.Execute (UnityEditor.Android.Постпроцессор.Контекст PostProcessorContext) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Постпроцессор.ПостПроцессРаннер.RunAllTasks (UnityEditor.Android.Постпроцессор.Контекст PostProcessorContext) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    Retrow as BuildFailedException: Исключение типа ‘UnityEditor.Строить.BuildFailedException’ был выброшен.
    UnityEditor.Android.ПостПроцессор.CancelPostProcess.AbortBuild (Система.Заголовок строки, Система.Строковое сообщение, Система.Исключение ex) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.ПостПроцессор.Постпроцессный раннер.RunAllTasks (UnityEditor.Android.ПостПроцессор.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Цель buildTarget, Система.Строка stagingAreaData, System.Строка StagingArea, System.Струнный плейерпакет, Система.Строка InstallPath, System.Строка CompanyName, System.Строка ProductName, UnityEditor.Параметры BuildOptions, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Строить.Отчет.Отчет BuildReport) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Модули.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup TargetGroup, UnityEditor.Цель buildTarget, Система.Строка InstallPath, System.Строка CompanyName, System.Строка ProductName, System.Int32 width, System.Int32 height, UnityEditor.Параметры BuildOptions, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Строить.Отчет.Отчет BuildReport) (at <7ca9a09aeae542ab86253a551b1c89a0>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    Пожалуйста, помогите мне решить эту проблему, это очень важно для меня! Я пытался как-то решить ее сам, но прошел месяц без каких-либо успешных попыток.
    P.s. Changing Gradle to your own, and not from Unity, did not help in any way (whatever versions were)

    Mister_Skinder:

    I can’t build a project, unity can’t get access to some servers and it doesn’t matter if I use a proxy or not. I can’t log in to the server itself either, I get the error 403 access denied.

    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Gradle\gradle-4.0.1\lib\gradle-launcher-4.0.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “bundleRelease”

    stderr[

    FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:launcher’.
  • Could not resolve all files for configuration ‘:launcher:classpath’.
    Could not resolve com.android.tools.build:gradle:4.0.1.
    Required by:
    project :launcher
    Could not resolve com.android.tools.build:gradle:4.0.1.
    Could not get resource ‘ https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom ’.
    Could not GET ‘ https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom ’. Received status code 403 from server: Forbidden

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

    BUILD FAILED in 9s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    stdout[
    Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
    Parallel execution is an incubating feature.
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Команда+WaitingForProcessToExit waitingForProcessToExit, System.String ErrorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Команда.Run (System.Строковая команда, Система.Строковые арги, Система.String workingdir, UnityEditor.Android.Команда+WaitingForProcessToExit waitingForProcessToExit, System.String ErrorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidJavaTools.Рунджава (Система.Строковые арги, Система.Строка workingdir, System.Действие ’ 1[T] прогресс, Система.Строковая ошибка) (при <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.ГрэдлеВраппер.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.Строка workingdir, System.Строковая задача, Система.Действие 1[T] прогресс) (at <25e82ad8f640476c8ff807f13e25668c>:0) Rethrow as GradleInvokationException: Ошибка сборки Gradle UnityEditor.Android.ГрэдлеВраппер.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.Строка workingdir, System.Строковая задача, Система.Действие 1[T] прогресс) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Постпроцессор.Задачи.BuildGradleProject.Execute (UnityEditor.Android.Постпроцессор.Контекст PostProcessorContext) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Постпроцессор.ПостПроцессРаннер.RunAllTasks (UnityEditor.Android.Постпроцессор.Контекст PostProcessorContext) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    Retrow as BuildFailedException: Исключение типа ‘UnityEditor.Строить.BuildFailedException’ был выброшен.
    UnityEditor.Android.ПостПроцессор.CancelPostProcess.AbortBuild (Система.Заголовок строки, Система.Строковое сообщение, Система.Исключение ex) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.ПостПроцессор.Постпроцессный раннер.RunAllTasks (UnityEditor.Android.ПостПроцессор.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Цель buildTarget, Система.Строка stagingAreaData, System.Строка StagingArea, System.Струнный плейерпакет, Система.Строка InstallPath, System.Строка CompanyName, System.Строка ProductName, UnityEditor.Параметры BuildOptions, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Строить.Отчет.Отчет BuildReport) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Модули.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup TargetGroup, UnityEditor.Цель buildTarget, Система.Строка InstallPath, System.Строка CompanyName, System.Строка ProductName, System.Int32 width, System.Int32 height, UnityEditor.Параметры BuildOptions, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Строить.Отчет.Отчет BuildReport) (at <7ca9a09aeae542ab86253a551b1c89a0>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)

    Do you have a custom baseProjectTemplate.gradle file? It looks like gradle is looking at a wrong repository. If you have a custom base project gradle file, make sure that “google” repository is specified before “jcenter” and the issue should be fixed for you. It should be similar to this:

    repositories {**ARTIFACTORYREPOSITORY**
        google()
        jcenter()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
     JuliusM:
    

    Есть ли у вас пользовательский файл baseProjectTemplate.gradle? Похоже, грэдл ищет не то хранилище. Если у вас есть пользовательский базовый файл проекта gradle, убедитесь, что репозиторий “google” указан перед “jcenter”, и проблема должна быть исправлена. Это должно быть похоже на это:

    репозитории {**ARTIFACTORYREPOSITORY**
    google()
    jcenter()
    флэтДир {
    dirs "${project(':unityLibrary').ProjectDir}/libs"
    

    I am not using my own baseProjectTemplate.gradle file.
    Attempts to use it lead to the same result as without it. I tried to clean up jcenter () or google (), but nothing came of it. I tried to replace jcenter () with mavenCentral () and it gave this error, although I have access to one link and the file is downloaded.

    CommandInvokationFailure: Gradle build failed. 
    C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    stderr[
    FAILURE: Build failed with an exception.
    * What went wrong:
    A problem occurred configuring project ':launcher'.
    > Could not resolve all artifacts for configuration ':launcher:classpath'.
       > Could not find com.android.tools.build:gradle:4.0.1.
         Searched in the following locations:
           - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom
           - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom
         Required by:
             project :launcher
    * 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.
    * Get more help at https://help.gradle.org
    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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <25e82ad8f640476c8ff807f13e25668c>: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 <7ca9a09aeae542ab86253a551b1c89a0>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    [/код]
                  

    The first link (dl.google) seems to be the correct one. Do you have a proxy setup in your machine? That might cause issues in this case. You can try exporting the project, importing it into Android Studio and building it there. Maybe Android Studio will manage to download gradle plugin 4.0.1 for you. You would have to dod that only once, since after it is downloaded for the first time, it will be cached on your machine, so you wouldn’t need to download it again. Then you would be able to build directly in Unity as well.

    JuliusM:

    The first link (dl.google) seems to be the correct one. Do you have a proxy setup in your machine? That might cause issues in this case. You can try exporting the project, importing it into Android Studio and building it there. Maybe Android Studio will manage to download gradle plugin 4.0.1 for you. You would have to dod that only once, since after it is downloaded for the first time, it will be cached on your machine, so you wouldn’t need to download it again. Then you would be able to build directly in Unity as well.

    I use a proxy. I can’t figure out how to build a project in Android Studio, so you can tell me exactly how to do it. Gradle 4.0.1.pom is downloaded from one of the links to me. Can I install it manually?

    mister-skinder:

    I use a proxy. I can’t figure out how to build a project in Android Studio, so you can tell me exactly how to do it. Gradle 4.0.1.pom is downloaded from one of the links to me. Can I install it manually?

    I don’t know why, but my exact same answer is not present, although I left it a couple of days ago

    I use a proxy. I can’t figure out how to build a project in Android Studio, so you can tell me exactly how to do it.

    Download Android Studio 4.0.1. Create a new android application and build it. If the build will succeed, then the Android Gradle Plugin 4.0.1 should get cached on your computer and then you should be able to build your Unity project directly in Unity as well.

    Gradle 4.0.1.pom is downloaded from one of the links to me. Can I install it manually?

    I don’t know how to do it. You would have to place it in a correct Gradle cache directory, but some of the subdirectories have hashed names, so I am not sure if you will be able to recreate correct directories.
    Gradle cache is in “%USERPROFILE%/.gradle/” on windows and in “~/.gradle/” on OSX. When gradle plugin is cached, it gets placed in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle and in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api There could be other locations where things are cached inside of .gradle/caches, but these two locations are what I was able to find.

    JuliusM:

    Download Android Studio 4.0.1. Create a new android application and build it. If the build will succeed, then the Android Gradle Plugin 4.0.1 should get cached on your computer and then you should be able to build your Unity project directly in Unity as well.

    I don’t know how to do it. You would have to place it in a correct Gradle cache directory, but some of the subdirectories have hashed names, so I am not sure if you will be able to recreate correct directories.
    Gradle cache is in “%USERPROFILE%/.gradle/” on windows and in “~/.gradle/” on OSX. When gradle plugin is cached, it gets placed in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle and in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api There could be other locations where things are cached inside of .gradle/caches, but these two locations are what I was able to find.

    I tried to install it manually, but to no avail. Attempts to build the project through Android Studio in the console says All files are up-to-date, how could I fix this?

    Did you try to build a new project, or some previously used project? Take a look at Build and run your app  |  Android Studio  |  Android Developers Android Studio documentation which explains how to build apps there.
    On the other hand, if you were able to build a new project with Android Studio 4.0.1, then Android Gradle Plugin 4.0.1 should have been downloaded and cached in your Gradle cache directories (mentioned previously), which should allow Unity editor to build using Android Gradle Plugin 4.0.1 as well.

    JuliusM:

    Did you try to build a new project, or some previously used project? Take a look at https://developer.android.com/studio/run Android Studio documentation which explains how to build apps there.
    On the other hand, if you were able to build a new project with Android Studio 4.0.1, then Android Gradle Plugin 4.0.1 should have been downloaded and cached in your Gradle cache directories (mentioned previously), which should allow Unity editor to build using Android Gradle Plugin 4.0.1 as well.

    Once the build in the android studio was successful, but I did not find the apk, but now there is a completely different error in the unity, what should I do?

    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    stderr[
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    FAILURE: Build failed with an exception.
    * What went wrong:
    Could not determine the dependencies of task ':launcher:compileReleaseJavaWithJavac'.
    > Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
    * 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.
    * Get more help at https://help.gradle.org
    BUILD FAILED in 9m 54s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    stdout[
    Starting a Gradle Daemon, 2 incompatible and 2 stopped Daemons could not be reused, use --status for details
    > Configure project :launcher
    WARNING: The option setting 'android.enableR8=false' is deprecated.
    It will be removed in version 5.0 of the Android Gradle plugin.
    You will no longer be able to disable R8
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Build-tool 31.0.0 is missing DX at C:\Android\SDK1\build-tools\31.0.0\dx.bat
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Build-tool 31.0.0 is missing DX at C:\Android\SDK1\build-tools\31.0.0\dx.bat
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <25e82ad8f640476c8ff807f13e25668c>: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, UnityEd<message truncated>
                  

    Now you are running into an issue described here Gradle build fails with build tools 31.0.0
    In short, in SDK you have installed build-tools 31.0.0 which does not work with Android Gradle Plugin 4.0.1 used by Unity. The recommended solution is to uninstall build-tools 31.0.0 and install an older version, such as build-tools 30.0.0

    Okay, the last error disappeared as I did as you said, but now there is this error

    CommandInvokationFailure: Gradle build failed.
    C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.1.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    stderr[
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    FAILURE: Build completed with 2 failures.
    1: Task failed with an exception.
    -----------
    * What went wrong:
    Execution failed for task ':launcher:mergeReleaseResources'.
    > Could not resolve all files for configuration ':launcher:_internal_aapt2_binary'.
       > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
         Required by:
             project :launcher
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
    * 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.
    ==============================================================================
    2: Task failed with an exception.
    -----------
    * What went wrong:
    Execution failed for task ':unityLibrary:compileReleaseLibraryResources'.
    > Could not resolve all files for configuration ':unityLibrary:_internal_aapt2_binary'.
       > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
         Required by:
             project :unityLibrary
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
          > Could not resolve com.android.tools.build:aapt2:4.0.1-6197926.
             > Could not get resource 'https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                > Could not GET 'https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/4.0.1-6197926/aapt2-4.0.1-6197926.pom'.
                   > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect
    * 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.
    ==============================================================================
    * Get more help at https://help.gradle.org
    BUILD FAILED in 27s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    stdout[
    > Configure project :launcher
    WARNING: The option setting 'android.enableR8=false' is deprecated.
    It will be removed in version 5.0 of the Android Gradle plugin.
    You will no longer be able to disable R8
    > Task :unityLibrary:preBuild UP-TO-DATE
    > Task :launcher:preBuild UP-TO-DATE
    > Task :launcher:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    > Task :launcher:generateReleaseBuildConfig UP-TO-DATE
    > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:generateReleaseResValues UP-TO-DATE
    > Task :unityLibrary:generateReleaseResources UP-TO-DATE
    > Task :launcher:compileReleaseAidl NO-SOURCE
    > Task :launcher:compileReleaseRenderscript NO-SOURCE
    > Task :launcher:javaPreCompileRelease UP-TO-DATE
    > Task :unityLibrary:packageReleaseResources UP-TO-DATE
    > Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
    > Task :launcher:generateReleaseResValues UP-TO-DATE
    > Task :launcher:generateReleaseResources UP-TO-DATE
    > Task :unityLibrary:processReleaseManifest
    > Task :launcher:mergeReleaseResources FAILED
    > Task :unityLibrary:compileReleaseLibraryResources FAILED
    9 actionable tasks: 3 executed, 6 up-to-date
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <25e82ad8f640476c8ff807f13e25668c>: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 <25e82ad8f640476c8ff807f13e25668c>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <25e82ad8f640476c8ff807f13e25668c>: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 <7ca9a09aeae542ab86253a551b1c89a0>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    

    I think it looks like my proxy, only with the wrong port, although I run Unity through the .cmd file with the correct ip and port. > Connect to 127.0.0.1:63041 [/127.0.0.1] failed: Connection refused: connect

    You can try to use Android Studio once again. Export your project in Unity, then open it in Android Studio and build once. If the build will succeed, then the dependencies will be downloaded and cached. After that you should be able to build directly in Unity editor as well.
    This is an ugly workaround, but it should help while Unity editor does not handle proxy settings correctly.

    JuliusM:

    You can try to use Android Studio once again. Export your project in Unity, then open it in Android Studio and build once. If the build will succeed, then the dependencies will be downloaded and cached. After that you should be able to build directly in Unity editor as well.
    This is an ugly workaround, but it should help while Unity editor does not handle proxy settings correctly.

    Okay, im try this again.

    JuliusM:

    You can try to use Android Studio once again. Export your project in Unity, then open it in Android Studio and build once. If the build will succeed, then the dependencies will be downloaded and cached. After that you should be able to build directly in Unity editor as well.
    This is an ugly workaround, but it should help while Unity editor does not handle proxy settings correctly.

    I got a successful build in Android studio and now I can build the project and in unity, thanks! You can close the topic :slight_smile:

    Hello in my case all the solutions doesn’t work.
    finally I export the project
    open in Android Studio
    It propose to upgrade gradle (in my case 3.4 to 7.1) and list some optional upgrade
    I check the upgrade gradle and optionnal upgrade
    I build the APK

    it’s working !!
    (without the gradle upgrade it doesn’t)

    regards

    Hello in my case all the solutions doesn’t work.
    finally I export the project
    open in Android Studio
    It propose to upgrade gradle (in my case 3.4 to 7.1) and list some optional upgrade
    I check the upgrade gradle and optionnal upgrade
    I build the APK

    it’s working !!
    (without the gradle upgrade it doesn’t)

    regards

    I want to try your sollution. I export my unity project and build it in andoid studio. But I cant import my project back into unity. I got:

    Project failed to open.
    This project is not valid

    Do you know what I did wrong?