When performing an Android build, the following error can be seen when Java 17 is expected in the build and the incorrect version of Java is being used:
Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.
> error: invalid source release: 17
To correct this issue, be sure to use the
Linux - 2023.04 build stack or later that supports Java 17. You will next want to update gradle to version 8 or greater in the build.gradle file or alternatively you can set the
OVERRIDE_JAVA_VERSION environment variable to
17 as described in this documentation.