FAILURE: Build failed with an exception.
What went wrong: A problem occurred
configuring project \':app\'.
If anyone else having the same problem with the above fix not working - then try installing JDK 1.8 instead of JDK 1.9 and set the JAVA_HOME environment variables. This fixed it for me.