The moment I added the android support annotations to my dependencies
compile \'com.android.support:support-annotations:20.0.0\'
I got this erro
In my case I had a file called cache.xml
under /build/intermediates/dex-cache/cache.xml
in the root project folder. I deleted this file, rebuild the project and it worked for me.
I deleted the android-support-v4.jar and it worked.
Explain - android-support-v4.jar is conflicting with my other .jar files of project\libs files ** specially when you are running with java 8 on AS.
The problem is that android-support-annotations.jar
used to be a separate library containing the android annotations, but for some reason these annotations are already included in recent versions of the android-support-v4.jar
file.
Deleting the annotations jar solved the issue.
I deleted the android-support-v4.jar and it worked.
Build->clean Project ,and it worked
As other users said, the first elements to troubleshoot are dependencies. Although, sometimes you can struggle for hours and you don't find any problem so you can focus on the build process instead.
Changing the way in which the .dex files are produced sometimes solves the problem. You can go through these steps:
Change it to:
dexOptions {
incremental false
}
If you don't find the task in your file then you can add it.