How to specify JDK version for gradle script
On one of my android application, it needs JDK 11, but I also installed the JDK 18 on my computer, so it reports errors when compile the…
On one of my android application, it needs JDK 11, but I also installed the JDK 18 on my computer, so it reports errors when compile the application, because it uses the jdk 18 as the default JDK.
Specify jdk for gradle script
My solution is update the gradlew
file to set JAVA_HOME to the specific jdk like below:
export JAVA_HOME=`$(/usr/libexec/java_home -v 11)`
With this change, the application can compile successfully.