My main goal was to create a new app, with just an Empty Activity: no bells nor whistles. However, after trying to be a good developer, and upgrade gradle, like the IDE said, everything went wrong.
Nothing would build anymore, it couldn't find my JDK, no matter where I put it, it couldn't edit the gradle dependency lock file: the whole nine. I managed to fix the JDK and gradle writing issue, by just moving everything, but I was then left with this last problem:
> No matching variant of com.android.tools.build:gradle:7.4.1 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:
Now, this isn't the full error. The full error, is a collapsed wall of text. However, I can reduce it a little bit, since this error is kind of recursive:
It starts out by saying:
A problem occurred configuring root project 'app'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.4.1.
Required by:
project : > com.android.application:com.android.application.gradle.plugin:7.4.1
project : > com.android.library:com.android.library.gradle.plugin:7.4.1
After that it lists a couple of things that used gradle v.7.4.1 in a particular capacity, but then the original problem occurred.
It seems like it's trying to use 7.4.1, but keeps finding 7.5, but I don't understand the rest. Then a repetitive error was logged, and centralized around some key elements (or 'variants', as they were), those elements being:
For each one it said something like this:
- Variant <insert variant here> capability com.android.tools.build:gradle:7.4.1 declares
a library, packaged as a jar, and its dependencies declared externally:
Then, for each one, it listed the..."reasons", why the "but:" had to be there, with the following being the parent reason:
component compatible with Java 11 and the consumer needed a runtime of a component
compatible with Java 8
which makes no sense to me, since I should be using Java...19, but maybe 19 is only the build version and not the advertised version (?) anyway...
The "other compatible attribute:" sub-reasons contained some of the following, which I will use the list numbers to simplify:
All variants had this one:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
and variants 2 and 4 had both of these:
- 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)
Now, I want to let you know that, yes, I did muck about with the settings at first, but when I found I wasn't making it any better, I uninstalled the entire IDE, including my user settings, and did a fresh download and installation of the newest version of the IDE. I checked the .android folder to find the .lib folder was gone, so maybe it worked (???), but I'm not sure, since it opened up an old project. I didn't remove any of the stuff that it wanted to see.
I'd like to use this image from another post here, which I also messed with in attempt to force it to use 7.5 by changing 7.4.1 to 7.5 and setting them to "true". It didn't work, so I put it back. Hopefully this was enough information to satisfy the original conditions:
Maybe it needs to move to a different sub-SO: I don't know, but I did my best here. Also if all above was completely abhorrent, I left most of the original error, untouched, down below. However, like I said, there is a more compressed version of this that goes even further but...I don't think you want 150+ lines of error to look at.
...
However, I can give you the top-level error:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'app'
...which just says the same thing.
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.1 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.1 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.1 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.1 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')
In AndroidStudio Flamingo 2022.2.1 I opened the File -> Settings menu, then I selected
Build, Execution, Deployment
Build Tools
Gradle
I selected my current project and in the "Gradle JDK" field I selected "Embedded JDK" (which happens to be v17.0.6). Closed the settings with OK, then clicked on "Try again" in the Gradle sync failure notice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With