it’s a prerequisite of Android SDK Is JDK so if you are installing the JDK and you know that you have JDK installed, it’s most probably that there’s a missing registry key that was not set

to solve this problem you need to add a registry key to fix this
so to do that
create a normal text file with this keys
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit]
"CurrentVersion"="1.6"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6]
"JavaHome"="C:\Program Files\Java\jdk1.6.0_25" "MicroVersion"="0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.6.0_23]
"JavaHome"="C:\Program Files\Java\jdk1.6.0_25" "MicroVersion"="0"
now rename the extension of the file to be “.reg” and then double click to install it, once done try to install it.
Update: please make sure that you have the correct path of JDK installed on your machine