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

相关推荐
数智化管理手记1 小时前
海量数据如何沉淀有效数据资产?数据标准化治理方案如何搭建?
java·大数据·人工智能
cfm_29142 小时前
SpringAI + Ollama 本地大模型
java·开发语言·人工智能·语言模型
鲸采云SRM采购管理系统3 小时前
采购管理系统哪家好?2026最新测评对比
java·服务器·数据库
阿pin3 小时前
Android随笔-kotlin withContext
android·kotlin·withcontext
0x534 小时前
Java网络编程(二)
java·服务器·网络
Flittly4 小时前
【雕虫大技】Agent 动态 Skill 供应链安全加固(三):输出校验与治理闭环实战
java·spring boot·spring
Poo_Chai4 小时前
QT emit信号后完整处理流程,包括槽函数响应流程
java·开发语言·数据库
瑞码空间4 小时前
Java 图形界面(GUI)完整知识点手册
java·开发语言·图形界面·swing
树码小子4 小时前
开启 IDEA 中的断言功能
android·java·intellij-idea
茶本无香5 小时前
Java调用Shell脚本执行SQL数据库操作:从入门到实战
java·sql·shell