If I run gradle assembleDebug
from the command line, I am suddenly getting this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexEx
Finally, I solved it modifiying these attributes on the module gradle file
I solved similar error by adding following piece of code to my build.gradle file inside the android block.
android {
dexOptions {
preDexLibraries = false
}
}
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
I've had the same issue. In my project, I had the following dependencies :
For legacy reasons, the appcompat was fetched from the Google Maven repo, whereas the android-support was a local .jar.
When I figured out this, and replaced this local reference with a maven reference, it just solved my build issue.
Here's the diff of my app/build.gradle :
Got it working for a compile file('...')
conflict by increasing minSdkVersion to 21 and enabling multidex. Not sure if that is the best solution but the only way I could get it working in my case.
Note: for compile file('...')
it appears that you cannot put in an exclude
clause so that option was not available.
I had the same problem and it seems that my app had too many methods because of the libraries: http://developer.android.com/tools/building/multidex.html
Solved it with:
android {
defaultConfig {
...
multiDexEnabled = true
}
}
More here Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2