在使用./gradlew build
编译项目时候遇到了该问题,整体错误如下:
* 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
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
该问题仅仅通过修改编译版本或者下载ndk无法解决文章来源:https://www.toymoban.com/news/detail-789229.html
参考链接:
jlink executable missing from bundled JDK11文章来源地址https://www.toymoban.com/news/detail-789229.html
到了这里,关于Could not resolve all files for configuration ‘:app:androidJdkImage‘.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!