gpt4 book ai didi

No matching variant of com.android.tools.build:gradle:7.4.0 was found(找不到com.android.tools.Build:Gradle:7.4.0的匹配变体)

转载 作者:bug小助手 更新时间:2023-10-28 20:51:24 25 4
gpt4 key购买 nike



I've just created a brand new material 3 compose project and this pops up:

我刚刚创建了一个全新的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')

Didn't change anything, everything is the default.

没有更改任何内容,一切都是默认设置。


更多回答

I also get this issue upgrading to 2022.1.1 and AGP 7.4.0. My JDK is set to 11

我也得到这个问题升级到2022.1.1和AGP 7.4.0。我的JDK设置为11

I also get this issue too on Giraffe. How can i solve this issue? There is no correct answer for my case at the below.

我在长颈鹿上也得到了这个问题。我怎么才能解决这个问题呢?对于我的情况,在下面没有正确的答案。

优秀答案推荐

Ended up changing Gradle JDK to 11.

最终将Gradle JDK更改为11。


File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

文件->设置->构建、执行、部署->构建工具->Gradle



For Mac users (as @Frederik pointed out), 'settings' is 'Preferences':
Preferences location

就像@Frederk指出的那样,对于Mac用户来说,‘设置’就是‘首选项’:


And then:

enter image description here

Finishing:

enter image description here

然后:完成:



If on Kotlin Multiplatform (KMM) upgrade to Java 17.

如果是在Kotlin多平台(KMM)上,则升级到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).

创建新KMM项目时,Android Studio的Gradle构建设置自动默认为Java 1.8(或为JAVA_HOME或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.

如果升级到Java 11或Java 13,它将成功构建并在Android Studio上运行,但不会在Xcode上成功构建或运行。


The way around (it seems) is to go up one more version to Java 17 (Amazon's corretto-17 in my case)

解决办法(似乎)是再升级一个版本到Java 17(在我的例子中是Amazon的Corretto-17)


corretto-17


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.

使用低于17的版本似乎打破了Xcode中预期的Gradle插件版本(但仅限于Xcode)--这带来了共享文件夹的范围问题。




Tested when creating a new project with CocoaPods and with Regular Framework.

在使用CocoaPods和Regular Framework创建新项目时进行测试。


Tested on Android Studio Flamingo alongside Xcode version 14.3

在Android Studio Flamingo和Xcode版本14.3上测试



Needed to do two steps...

需要做两个步骤。


Change Gradle JDK to 11.

将Gradle JDK更改为11。


File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

文件->设置->构建、执行、部署->构建工具->Gradle


then

然后


File -> Repair IDE.
Ran through each of the steps until it restarted and then started downloading a load of files. Build worked after this.

文件->修复IDE。已运行每个步骤,直到重新启动,然后开始下载大量文件。在此之后,Build起作用了。



If you make adjustments like this in the latest version Android Studio Flamingo | 2022.2.1, you will not have any problems.

如果你在最新版本的Android Studio Flamingo|2022.2.1中进行这样的调整,你不会有任何问题。


build.gradle(project)

Build.gradle(项目)


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)

Build.gradle(:APP)


...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
...

Gradle JDK settings:

分级JDK设置:


enter image description here



There are two ways to change Gradle JDK to 11.

有两种方法可以将Gradle JDK更改为11。



  1. File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle



  2. or config in gradle.properties:


    "org.gradle.java.home= /xxx/Java/jdk-11.0.1"





File > Manage IDE Settings > Restore Default Setting

文件>管理IDE设置>恢复默认设置


This worked for me on Electric Eel

这对我在电鳗上很管用



It also happened to me and the only option I found was to reinstall the project. When reinstalling I exported the settings and when it happens again I import them.

这也发生在我身上,我找到的唯一选择就是重新安装项目。在重新安装时,我会导出设置,当再次发生这种情况时,我会导入它们。


更多回答

Electric Eel is weird. First I had this with a Flutter project: stackoverflow.com/questions/51281702/… and then now with an Android project this seems to be also a problem with JDK version. Why did it reset those?

电鳗很奇怪。首先,我有一个颤动项目:Stackoverflow.com/Questions/51281702/…现在,对于Android项目,这似乎也是JDK版本的问题。它为什么要重置那些?

This is madness! I'm having this issue as well.

这太疯狂了!我也有这个问题。

Note that on macOS the settings are under the "Android Studio" menu. I just selected "Embedded JDK" here, which is the JDK bundled with Android Studio.

请注意,在MacOS上,这些设置位于“Android Studio”菜单下。我在这里刚刚选择了嵌入式JDK,这是与Android Studio捆绑的JDK。

While creating a new project in Electic Eel variant of Android Studio, the mentioned issues arrise. It is basically compelling the developer to use JDK 11 instead of 1.8. Problem will be fixed after doing the same. Thanks

在Android Studio的Electrtic Eel Variant中创建新项目时,出现了上述问题。它基本上迫使开发人员使用JDK 11而不是1.8。在执行相同操作后,问题将得到解决。谢谢

Encountered this while trying to run reactivecircus/android-emulator-runner@v2 on github actions. Adding actions/setup-java@v3 before running the emulator runner and setup JDK to 11 solved the issue.

尝试在GitHub操作上运行reactive ecircus/android-模拟器-runner@v2时遇到此问题。在运行仿真器运行器并将jdk设置为11之前添加action/setup-java@v3解决了这个问题。

Had the same issue when trying to publish my package to jitpack.io, and upgrading the jdk in jitpack.yml with openjdk17 indeed helped with the issue :D

在尝试将我的包发布到jitpack.io时也遇到了同样的问题,用openjdk17升级jitpack.yml中的jdk确实解决了这个问题:D

Just did it. Not working for me

就这么做了。不为我工作

This is the only thing that worked for me, thank you! (On Flamingo)

这是唯一对我有效的方法,谢谢!(关于火烈鸟)

This did not work.. and it actually resets everything from android studio and you need to download all the SDK stuffs again

这不管用..它实际上重置了Android Studio中的所有内容,您需要再次下载所有SDK内容

Complement: The solution given by Joseph Mota worked for me.

补充:约瑟夫·莫塔给出的解决方案对我很管用。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com