I have found a solution. I think Android Studio used 2 java compilers, one built into android studio, and the other the one I installed to install Android Studio.
In Android Studio , in the menu File → Project Structure : change the default JDK location directory to your own, in my case it was:
/ Usr / local / android studio / jre
and i changed to
/usr/local/java/jdk1.8.0_111 #path_to_your_jdk
which is the version I installed.

source share