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

相关推荐
customer083 小时前
【开源免费】基于SpringBoot+Vue.JS体育馆管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
Miketutu4 小时前
Spring MVC消息转换器
java·spring
乔冠宇4 小时前
Java手写简单Merkle树
java·区块链·merkle树
LUCIAZZZ5 小时前
简单的SQL语句的快速复习
java·数据库·sql
komo莫莫da5 小时前
寒假刷题Day19
java·开发语言
S-X-S6 小时前
算法总结-数组/字符串
java·数据结构·算法
linwq86 小时前
设计模式学习(二)
java·学习·设计模式
桦说编程7 小时前
CompletableFuture 超时功能有大坑!使用不当直接生产事故!
java·性能优化·函数式编程·并发编程
@_@哆啦A梦7 小时前
Redis 基础命令
java·数据库·redis
恋猫de小郭7 小时前
Android Studio 正式版 10 周年回顾,承载 Androider 的峥嵘十年
android·ide·android studio