Gradle build error. Build failed with an exception

I get this error when I try to build my game for Android in Unity. How do I get rid of that?

FAILURE: Build failed with an exception.

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

Could not resolve all task dependencies for configuration ‘:launcher:debugRuntimeClasspath’.
Did not resolve ‘android.arch.lifecycle:livedata-core:1.1.1’ which is part of the dependency lock state
Did not resolve ‘android.arch.lifecycle:viewmodel:1.1.1’ which is part of the dependency lock state
Resolved ‘androidx.lifecycle:lifecycle-service:2.0.0’ which is not part of the dependency lock state
Did not resolve ‘android.arch.lifecycle:runtime:1.1.1’ which is part of the dependency lock state
Did not resolve ‘com.android.support:support-fragment:26.1.0’ which is part of the dependency lock state
Did not resolve ‘android.arch.lifecycle:common:1.1.1’ which is part of the dependency lock state
Resolved ‘androidx.lifecycle:lifecycle-process:2.0.0’ which is not part of the dependency lock state
Did not resolve ‘com.android.support:support-annotations:26.1.0’ which is part of the dependency lock state
Did not resolve ‘android.arch.core:runtime:1.1.1’ which is part of the dependency lock state
Did not resolve ‘android.arch.lifecycle:livedata:1.1.1’ which is part of the dependency lock state
Did not resolve ‘android.arch.lifecycle:extensions:1.1.1’ which is part of the dependency lock state
Resolved ‘androidx.lifecycle:lifecycle-extensions:2.0.0’ which is not part of the dependency lock state
Did not resolve ‘android.arch.core:common:1.1.1’ which is part of the dependency lock state
Did not resolve ‘com.android.support:support-compat:26.1.0’ which is part of the dependency lock state
Did not resolve ‘com.android.support:support-core-utils:26.1.0’ which is part of the dependency lock state
Did not resolve ‘com.android.support:support-core-ui:26.1.0’ which is part of the dependency lock state

  • 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

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

Tried adding ‘:launcher’ next to ‘:unityLibrary’ in My project\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build.gradle dependencies { implementation project(‘:unityLibrary’)} and got a new error. The first one seems to be gone.
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • Where:
    Build file ‘C:\My project\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build.gradle’ line: 4

  • What went wrong:
    A problem occurred evaluating project ‘:launcher’.

Could not find method project() for arguments [:unityLibrary, :launcher] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

  • 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:
    A problem occurred configuring project ‘:launcher’.

compileSdkVersion is not specified. Please add it to build.gradle

  • 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 2s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

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

Were you ever able to get this completely resolved? I’m having the same issue.