任务“:google_sign_in_android:compileDebugJavaWithJavac”执行失败

问题描述 投票:0回答:1

我的目标SDK是34,flutter升级并清理后,下载新的依赖项。

使用最新版本的 google_sign_in (

^6.2.2
),Java 17。

> flutter build appbundle --debug     

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':google_sign_in_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':google_sign_in_android: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: ~/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path ~/.gradle/caches/8.9/transforms/a8ccf02f3bd250ddd23a149d57050286-edb8a5f8-325c-4293-8c19-e22390005e69/transformed/output/temp/jmod --add-modules java.base --output ~/.gradle/caches/8.9/transforms/a8ccf02f3bd250ddd23a149d57050286-edb8a5f8-325c-4293-8c19-e22390005e69/transformed/output/jdkImage --disable-plugin system-modules}

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 9s
Running Gradle task 'bundleDebug'...                               10.0s
Gradle task bundleDebug failed with exit code 1

> java --version
openjdk 17.0.5 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

尝试将依赖关系降级为

6.1.6
及更早版本。发布时效果良好。

java android flutter
1个回答
0
投票

显然 flutter 使用的是不同版本的 Java,默认的

java
位于
/usr/bin/java

通过运行

java --version
,它显示版本 17,但使用
flutter doctor -v
,我能够看到
Java version OpenJDK Runtime Environment (build 21...)
,它是 Android Studio 提供的 (
Java binary at: /Applications/Android Studio.app/...
)

使用

flutter config --jdk-dir /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/
将java版本更改为版本17,匹配gradle版本,解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.