I use Android Studio and recently got the error:
Error:Execution failed for task \':app:compileDebugJavaWithJavac\'. compileSdkVersion \'android-24\' re
In Android Studio open: File > Project Structure > see if JDK location points to your JDK 1.8 directory.
File
Project Structure
Note: you can use compileSdkVersion 24
compileSdkVersion 24