This was driving me nuts for a while. I was able to fix it by explicitly setting the java version in my build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Note that if you’re using VERSION_1_7, when you cold launch Android Studio or switch to another project that uses VERSION_1_8, it will modify .idea/misc.xml to use JDK_1_8. Doing a gradle sync will revert it back to using JDK_1_7. If you’re using VERSION_1_8, you won’t have this issue.
It’s not perfect but I found this to be good enough for now.