When try to update distribution gradle url to
https://services.gradle.org/distributions/gradle-7.6.1-bin.zip
getting below error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildSrc:generateExternalPluginSpecBuilders'.
> Could not resolve all files for configuration ':buildSrc:compileClasspath'.
> Could not resolve com.android.tools.build:gradle:7.4.2.
Required by:
project :buildSrc
> No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably not packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1', attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares an API of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them preferably not packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them preferably not packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
* 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
> Task :buildSrc:generateExternalPluginSpecBuilders FAILED
1 actionable task: 1 executed
*********************************************
Static Analysis Failed
Please fix the above issues before committing
*********************************************
Things I checked so far to resolve it
- Cleared the gradle caches
- Checked JDK supported version (It’s 11)
Versions
- Android studio version (Electric Eel | 2022.1.1 Patch 2)
- gradle version (7.4.2)
- Mac version (13.1)
- git version (2.37.1)
2
Answers
I had the same error!
Do it:
In the android/build.gradle file, change the dependencies line to "gradle:7.4.2":
In the android/gradle/wrapper/gradle-wrapper.properties, change the version of gradle:
Go to the android directory and run the command:
Hope this fixes it and helps you.
We’ve all seen these basic configuraiton issues in Android Studio for a long time. Would be nice to see some improvements there.