How the fix the gradle error in Android studio after update preview 3?

How the fix the gradle error in Android studio after update preview 3?

You should download the latest jdk
Install it.
Then in Android Studio go to:
File-->Other Settings-->Default Project Structure
And change the location of the JDK Location for the new one:
Also set your java home to 1.8 by command line:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
I had to update my Android Studio to the latest version to solve the problem. My JAVA_HOME and JDK were well configurated and was not a problem of compilation/running version. I don't know why, but just solve it when I updated AS to latest version.