I am using Android Studio 0.4.2. Opened project from a friend who is using 0.3.2. Tried to compile but got exception.
Execution failed for task \':JuiceTV:d
This happens when a Module has a dependency on both another module and that same module's jar.
I had this issue on android studio 1.0, along with removing the duplicate entry for libraries you should also try deleting the bin folders and do a clean build.
Having multiDex disabled and incremental in dexOptions enabled will also cause this issue.
defaultConfig {
multiDexEnabled = false
}
dexOptions {
javaMaxHeapSize "4g"
incremental true
}
As of Android Gradle 1.0 this can happen a few ways:
If you only use Maven repos you can run into this issue if two different artifacts include the same class file.
The Mockito-all library, for instance, includes Hamcrest and you would therefore cause this error if you included both dependencies in a build.
Note, if you have minification turned on you won't see the error until you start using Hamcrest. The way to resolve this is to use a version of the library that isn't including other package's classes (Mockito-core in this case).
If you declare a local jar/aar dependency (compile 'com.some.library:some-artiface-version_number@aar'
) that is already being included by other maven-based dependencies.
In this situation your local declaration doesn't get de-duped with the Maven one because the pom information isn't available. You would typically create a local, file-based maven repo for the aar to get around this.
In either case, a project clean is required to pickup the changes.
I just had the same issue and I discovered that my application and a library were referring to 2 versions of the same jar.
I did a search and my application.iml file clearly showed the duplicates.
<orderEntry type="library" exported="" name="crittercism_v3_0_11_sdkonly" level="project" />
<orderEntry type="library" exported="" name="crittercism_v4_4_0" level="project" />
I replaced the older v3 version with the v4 version and it worked after a clean rebuild.