Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Could not call IncrementalTask.taskAction() on task ':project:dexDebug'

I recently decided to switch from Eclipse to Android Studio. I imported a project I was working on and am now getting this error when I try to run the project.

Gradle: Execution failed for task ':project:dexDebug'.
> Could not call IncrementalTask.taskAction() on task ':project:dexDebug'

I've been cruising this site for 2 days now and trying different suggestions to no avail. I did run gradlew compileDebug --stacktrace and this is what I got:

C:\Users\adam\AndroidStudioProjects\projectProject>gradlew compileDebug --stacktrace
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:project:preBuild UP-TO-DATE                                                                        
:project:preDebugBuild UP-TO-DATE  
:project:preReleaseBuild UP-TO-DATE  
:project:prepareComAndroidSupportAppcompatV71800Library UP-TO-DATE  
:project:prepareComGoogleAndroidGmsPlayServices3225Library UP-TO-DATE  
:project:prepareDebugDependencies             
:project:compileDebugAidl UP-TO-DATE  
:project:compileDebugRenderscript UP-TO-DATE  
:project:generateDebugBuildConfig UP-TO-DATE  
:project:mergeDebugAssets UP-TO-DATE  
:project:mergeDebugResources UP-TO-DATE  
:project:processDebugManifest UP-TO-DATE  
:project:processDebugResources UP-TO-DATE  
:project:generateDebugSources UP-TO-DATE  
:project:compileDebug UP-TO-DATE  

BUILD SUCCESSFUL

Total time: 10.459 secs

However I am still getting that error when I try to actually run the project. Here is my build.gradle (i do have a 'libs' folder in my project with all the jars for a google maps/places app):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 18
    }
}

dependencies {
    compile fileTree(dir: 'libs')
    compile 'com.google.android.gms:play-services:3.2.25'
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:appcompat-v7:+'
}

and my settings.gradle:

include ':project', ':project:libs:android-support-v4', ':project:libs:google-api-client-1.10.3-beta',
        ':project:libs:google-api-client-android2-1.10.3-beta', ':project:libs:google-http-client-1.10.3-beta',
        ':project:libs:google-http-client-android2-1.10.3-beta', ':project:libs:google-oauth-client-1.10.1-beta',
        ':project:libs:gson-2.1', ':project:libs:guava-11.0.1', ':project:libs:jackson-core-asl-1.9.4',
        ':project:libs:jsr305-1.3.9', ':project:libs:protobuf-java-2.2.0', ':project:libs:GoogleAdMobAdsSdk-6.4.1'

As I said, I've tried pretty much everything I have read on here about this error and am having no luck. Any help would be greatly appreciated.

like image 841
akenawell85x Avatar asked Oct 31 '13 14:10

akenawell85x


2 Answers

If your issue is the same as mine, the problem is a conflict between library dependencies.

In my case, the culprit was a 3rd-party library jar inside the libs directory, which included the android-support-v4 library. This conflicted with my project's dependency on the support library (i.e. the compile 'com.android.support:support-v4:18.0.0' line in build.gradle).

Once I updated to a version of the 3rd-party library which did not need/include the support library, the problem was solved.

The reason you do not see any problems when issuing the compileDebug task, is that the problem manifests itself during the dexDebug phase (when gradle merges the bytecode from all projects and libraries, kinda the linking phase in C/C++ projects).

Try instead with ./gradlew [clean] assembleDebug

like image 92
Giorgos Kylafas Avatar answered Oct 20 '22 18:10

Giorgos Kylafas


Thought i should quickly share my experience on this one as just had the same issue, but resolved now. So if it helps anyone else.

I'm using android studio as well and was playing around with layouts and loading them using my code, so not having standard "layout/layout-land" type folders..

Anyway, i corrected any code and rolled back my changes stage by stage with no luck on resolving the error.. Then i noticed a warning about the folder name not being accepted.. was something simple like "layout-alternative1234"

Anyway, renamed the folder and no change. Restarted IDE and the same deal... Checked the warning again noticed it was located in the debug folders..

Rebuild Project in this case resolved the issue quickly for me, normally i would rebuild during most structure changes... but must have forgotten this time.

like image 41
Angry 84 Avatar answered Oct 20 '22 17:10

Angry 84