You just saved me a few hours of my life. I don't know why, but Android Studio has some issues with adding modules. I was having a DuplicatedFile exception due this:
compile project(path: ':backend', configuration: 'android-endpoints')
Without the second compile, I was unable to access the backend api. With the second compile, the exception appears. After reading this:
Tip: Keep in mind that anytime you make any changes to your build files, do remember to click on the Sync Project with Gradle Files as shown below. It should launch the build and you should be able to see the Gradle commands getting executed in the Gradle Console
My problem was solved! No more two compiles for same module in gradle.
I never had to push this button, it wasn't necessary until now.
Thanks for this post. Very useful!