> No matching variant of com.android.tools.build:gradle:7.4.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.0 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 version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- 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.5')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.0 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 version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
Didn't change anything, everything is the default.
–
–
–
–
Needed to do two steps...
Change Gradle JDK to 11.
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
File -> Repair IDE.
Ran through each of the steps until it restarted and then started downloading a load of files. Build worked after this.
If on Kotlin Multiplatform (KMM) upgrade to Java 17.
When you create a new KMM project Android Studio's Gradle build setting auto-defaults to Java 1.8
(or whatever is specified for JAVA_HOME or org.gradle.java.jome).
If you upgrade to Java 11
or Java 13
it'll build successfully and run on Android Studio but it won't Build or Run successfully on Xcode.
The way around (it seems) is to go up one more version to Java 17
(Amazon's corretto-17 in my case)
It seemed like using a version lower than 17 was breaking the expected Gradle plugin version in Xcode (but only on Xcode) - which introduces scope issues with the shared
folder.
Tested when creating a new project with CocoaPods and with Regular Framework.
Tested on Android Studio Flamingo
alongside Xcode version 14.3
If you make adjustments like this in the latest version Android Studio Flamingo | 2022.2.1
, you will not have any problems.
build.gradle(project)
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
build.gradle(:app)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
Gradle JDK settings:
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.