Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Android Gradle preDexDebug "Source and destination must be different" build failed?

Tags:

I have an Android application built with Android Studio 0.8.1 and facing the issue:

Error:Execution failed for task ':app:preDexDebug'. > java.lang.IllegalArgumentException: Source C:\Users\mfedorov\AndroidStudioProjects\EPOS2\app\build\intermediates\pre-dexed\debug\mate-api-0.0.1-SNAPSHOT-0ef7e3259aeaf19202f545da97dc6b1ae2502c9a.jar and destination C:\Users\mfedorov.ALTIUS-PLUS\AndroidStudioProjects\EPOS2\app\build\intermediates\pre-dexed\debug\mate-api-0.0.1-SNAPSHOT-0ef7e3259aeaf19202f545da97dc6b1ae2502c9a.jar must be different 

Here's my build.gradle file contents (the part that I have changed, the rest is default)

configurations.all {     // check for updates every build     resolutionStrategy.cacheChangingModulesFor 0, 'seconds' }  dependencies {     compile fileTree(dir: 'libs', include: ['*.jar'])      compile 'org.apache.commons:commons-collections4:4.0'     compile 'org.slf4j:slf4j-android:1.7.7'     compile 'com.altius.logging:logging-utils:0.0.1-SNAPSHOT'     compile group: "com.altius.mate", name: "mate-bluetooth", version: "0.0.1-SNAPSHOT", changing: true     compile group: "com.altius.mate", name: "mate-api", version: "0.0.1-SNAPSHOT", changing: true     //compile('org.simpleframework:simple-xml:2.7.1') {     //exclude group: 'stax', module: 'stax-api'     //exclude group: 'xpp3', module: 'xpp3'     //}  } 

contents of the root build.gradle are default as created with android project

mate-api-0.0.1-SNAPSHOT artifacts are from Maven local repository mavenLocal()

like image 670
Mikhail Boyarsky Avatar asked Jul 22 '14 11:07

Mikhail Boyarsky


People also ask

Why does Gradle build fail?

When Gradle is unable to communicate with the Gradle daemon process, the build will immediately fail with a message similar to this: $ gradle help Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details FAILURE: Build failed with an exception.

How do I change the gradle path in Android Studio?

To change its path go to this path File > Settings... > Build, Execution, Deployment > Gradle In the Global Gradle settings Change Service directory path to what you want.

What is @AAR in gradle?

The AAR format. is the binary distribution of an Android Library Project. As described here in the official Android Tools documentation. In your case, when adding a compile dependency in an Android Gradle project, adding "@aar" means that you would like to fetch the @aar file and not a regular JAR file.

What is the purpose of the gradle in Android Studio and at what point can its content be modified?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.


1 Answers

The answer was just to clean the project. I was having same problem for some time.

Build -> Clean Project

like image 103
Napuu Avatar answered Sep 19 '22 15:09

Napuu