gradle React Native Expo eas build -p android的Java JDK版本错误

wrrgggsh  于 2022-11-14  发布在  React
关注(0)|答案(2)|浏览(179)

执行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路径是否会有任何作用。

iezvtpos

iezvtpos1#

我也遇到了同样的错误。下面的解决方案为我修复了Java 11 vs 8的问题,但我现在遇到了另一个错误-无法创建任务“:app:prepareLintJarForPublish”。
查看这里以获得更多信息。原来EAS默认是使用JDK 8。

解决方案:

将其添加到eas.json文件中

"production": {
  "android": {
    "image" : "latest"
  }
 }
gopyfrb3

gopyfrb32#

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

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

相关问题