Android SDK installation doesn't find JDK
If the Android SDK installation is unable to find the JDK (Java Development Kit), it could be because the JDK is not installed or is not installed in the default location.
If the Android SDK installation is unable to find the JDK (Java Development Kit), it could be because the JDK is not installed or is not installed in the default location. Note that Android Studio typically bundles its own JDK, which resolves this issue automatically.
To fix this issue, you have a few options:
- Install the JDK: If you do not have the JDK installed, you can download and install an OpenJDK distribution. Adoptium (Eclipse Temurin) is the officially recommended distribution for Android development: https://adoptium.net/
- Set the
JAVA_HOMEenvironment variable: If you have the JDK installed but it is not in the default location, you can set theJAVA_HOMEenvironment variable to point to the JDK root directory. To do this on Windows, follow these steps:- Open the Control Panel and go to "System and Security > System > Advanced System Settings".
- Click on the "Environment Variables" button.
- Under "System Variables", scroll down and find the "JAVA_HOME" variable. If it does not exist, click the "New" button to create it.
- Set the "JAVA_HOME" variable to the location of the JDK installation. For example:
C:\Program Files\Java\jdk1.8.0_251 - Click "OK" to save the changes. Note: You may need to restart your terminal or IDE for the changes to take effect.
For macOS or Linux, add the following line to your shell profile (e.g., ~/.bashrc or ~/.zshrc), replacing the path with your actual JDK location:
export JAVA_HOME="/path/to/jdk"
Then, apply the changes by running source ~/.bashrc (or source ~/.zshrc) or by restarting your terminal.
After setting the JAVA_HOME environment variable, verify it is configured correctly by running echo $JAVA_HOME or java -version. You should then be able to install the Android SDK successfully.
Note: JAVA_HOME must always point to the JDK root directory, not the bin folder. For example: C:\Program Files\Java\jdk1.8.0_251