'Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. **EXPO.dev**

I'm trying to use the command eas build -p android to build my android .aab file, but each time I'm trying to do so, then I'm finding the error

🤖 Android build failed:
Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

After checking the build on https://expo.dev/accounts/xyz/projects/abc/builds/abababababa... I'm finding the error in the title with the whole logs below:

Running './gradlew :app:bundleRelease' in /home/expo/workingdir/build/android
Downloading https://services.gradle.org/distributions/gradle-7.2-all.zip
Unzipping /home/expo/.gradle/wrapper/dists/gradle-7.2-all/260hg96vuh6ex27h9vo47iv4d/gradle-7.2-all.zip to /home/expo/.gradle/wrapper/dists/gradle-7.2-all/260hg96vuh6ex27h9vo47iv4d
Set executable permissions for: /home/expo/.gradle/wrapper/dists/gradle-7.2-all/260hg96vuh6ex27h9vo47iv4d/gradle-7.2/bin/gradle
Welcome to Gradle 7.2!
Here are the highlights of this release:
 - Toolchain support for Scala
 - More cache hits when Java source files have platform-specific line endings
 - More resilient remote HTTP build cache behavior
For more details see https://docs.gradle.org/7.2/release-notes.html
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
[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 48s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
Unable to list file systems to check whether they can be watched. The whole state of the virtual file system has been discarded. Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory)
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

There are online resources showing how to fix it in the Android Studio, but anyone knows how to fix this when your build is being triggered by expo.dev?



Solution 1:[1]

Fixed by adding into eas.json:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel Danielecki