If I run gradle assembleDebug from the command line, I am suddenly getting this error:
gradle assembleDebug
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.util.DexEx
In my case the problem was caused by version inconsistency:
Build tools 25 compileSdk 24 targetSdk 24 Support library 24
The solution was simple: Make everything version 25