React Native Expo eas build -p android java JDK 版本错误

运行 eas build -p android 会产生以下结果:

stderr] FAILURE: Build failed with an exception.
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/android/app/build.gradle' line: 1
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':app'.
[stderr] > Failed to apply plugin 'com.android.internal.application'.
[stderr]    > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
[stderr]      You can try some of the following options:
[stderr]        - changing the IDE settings.
[stderr]        - changing the JAVA_HOME environment variable.
[stderr]        - changing `org.gradle.java.home` in `gradle.properties`.
[stderr] * Try:
[stderr] 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.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 40s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

我看不到从我的 expo 托管项目的 android 文件夹中升级我的 java jdk 版本的地方,并且当前版本 1.8 似乎没有在任何地方列出。该构建在 eas 服务器上运行,所以我怀疑指向本地 JDK 路径是否会做任何事情。

stack overflow React Native Expo eas build -p android has wrong java JDK version
原文答案

答案:

作者头像

我也有同样的错误。以下解决方案为我解决了 Java 11 vs 8 问题,但我现在遇到了另一个错误 - 无法创建任务“:app:prepareLintJarForPublish”。

查看 here 了解更多信息。原来eas默认是使用jdk 8。

解决方案:

将此添加到您的 eas.json 文件中

"production": {
  "android": {
    "image" : "latest"
  }
 }
作者头像

我使用以下方法修复了我的:

"production": {
  "android": {
    "image" : "ubuntu-18.04-jdk-11-ndk-r19c"
  }
 }

相关问题