How do I tell Gradle to use specific JDK version?

To specify the JDK version that Gradle should use, you can include the property in the file in the root project directory.

For example, to use JDK 8:\\Program Files\\Java\\jdk1.8.0_241

You can also specify the JDK version in the build.gradle file of your project by including the java-home property in the android block.

For example:

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

    java-home = 'C:\\Program Files\\Java\\jdk1.8.0_241'

Keep in mind that you will need to have the specified JDK version installed on your system for this to work. You can check which JDK versions are installed on your system by running the java -version command from the command prompt.