No matching variant of com.android.tools.build:gradle:7.4.0 was found
回答 3
浏览 4199
2023-01-13
我刚刚创建了一个新的material 3 compose项目,就弹出了这样的内容:
> 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')
没有改变任何东西,所有东西都是默认的。
我在升级到2022.1.1和AGP 7.4.0时也遇到这个问题。我的JDK被设置为11
- Amit Nayar 2023-01-16
3 个回答
#1楼
已采纳
得票数 39
最终把Gradle JDK改成了11。
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Electric Eel很奇怪。首先,我在一个Flutter项目中遇到了这个问题。stackoverflow.com/questions/51281702/…,然后现在在一个Android项目中,这似乎也是一个JDK版本的问题。为什么它要重置这些?
- Csaba Toth 2023-01-16
确实很奇怪。不知道这是怎么回事,但我的答案似乎是一个解决方案。
- Juncu 2023-01-17
看起来这个问题是针对每个项目的。我需要在所有的项目中纠正它。这真是太疯狂了。
- Csaba Toth 2023-01-18
这真是太疯狂了!我也有这个问题。
- jenndotcodes 2023-01-24
注意,在macOS上,设置在"Android Studio"菜单下。我只是在这里选择了"Embedded JDK",也就是Android Studio捆绑的JDK。
- Frederik 2023-02-02
#2楼
得票数 0
File > Manage IDE Settings > Restore Default Setting
这对我来说在 Electric Eel上很有效。
刚做完。对我不起作用
- SndrSchnklshk 2023-01-30
#3楼
得票数 0
这也发生在我身上,我发现的唯一选择是重新安装项目。在重新安装时,我导出了设置,当它再次发生时,我就导入它们。
补充。Joseph Mota给出的解决方案对我很有效。
- Renan Moreira 2023-02-20