Could not resolve all files for configuration ‘:app:androidJdkImage‘.

在使用./gradlew build编译项目时候遇到了该问题,整体错误如下:

shell 复制代码
* What went wrong:
Configuration cache state could not be cached: field `generatedModuleFile` of `com.android.build.gradle.tasks.JdkImageInput` bean found in field `compilerArgumentProviders` of `org.gradle.api.tasks.compile.CompileOptions` bean found in field `capturedArgs` of `java.lang.invoke.SerializedLambda` bean found in field `spec` of `org.gradle.api.internal.tasks.execution.SelfDescribingSpec` bean found in task `:app:compileDebugJavaWithJavac` of type `org.gradle.api.tasks.compile.JavaCompile`: error writing value of type 'org.gradle.api.internal.provider.TransformBackedProvider'
> Could not resolve all files for configuration ':app:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: /Users/ym/Work/AndroidDevelop/AndroidSdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/jlink with arguments {--module-path /Users/ym/.gradle/caches/transforms-3/9238aeceb3486cd22cebc21db321c758/transformed/output/temp/jmod --add-modules java.base --output /Users/ym/.gradle/caches/transforms-3/9238aeceb3486cd22cebc21db321c758/transformed/output/jdkImage --disable-plugin system-modules}

可以看出使用的sdk版本为34,java版本为21.

解决办法为,修改java版本为17。本地重新下载Java17的jdk,这样本地就会有21、17两个版本,然后在项目中指定依赖的java版本17并配置路径(也可以配置环境变量)
gradle.properties

shell 复制代码
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home

该问题仅仅通过修改编译版本或者下载ndk无法解决

参考链接:
jlink executable missing from bundled JDK11

相关推荐
骆晨学长7 分钟前
基于springboot的智慧社区微信小程序
java·数据库·spring boot·后端·微信小程序·小程序
AskHarries12 分钟前
利用反射实现动态代理
java·后端·reflect
@月落13 分钟前
alibaba获得店铺的所有商品 API接口
java·大数据·数据库·人工智能·学习
liuyang-neu18 分钟前
力扣 42.接雨水
java·算法·leetcode
z千鑫22 分钟前
【人工智能】如何利用AI轻松将java,c++等代码转换为Python语言?程序员必读
java·c++·人工智能·gpt·agent·ai编程·ai工具
Flying_Fish_roe36 分钟前
Spring Boot-Session管理问题
java·spring boot·后端
赚钱给孩子买茅台喝37 分钟前
智能BI项目第四期
java·spring boot·spring cloud·aigc
运维Z叔1 小时前
云安全 | AWS S3存储桶安全设计缺陷分析
android·网络·网络协议·tcp/ip·安全·云计算·aws
陈大爷(有低保)2 小时前
UDP Socket聊天室(Java)
java·网络协议·udp
kinlon.liu2 小时前
零信任安全架构--持续验证
java·安全·安全架构·mfa·持续验证