Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution failed for task mockableAndroidJar, mockable-android- . jar already exists

I am facing issue with Android Studio 3, gradle android plugin 3 with build target 27 and support lib 27.0.0

Error:Execution failed for task ':module:mockableAndroidJar'.
> Output file [[...]/build/generated/mockable-android-27.v3.jar] already exists.

I have to clean or manually delete all mockable-android jars from the generated folder time to time. So this means instead of getting better build times, I have to clean the project most of the times.

like image 285
Gaurav Vashisth Avatar asked Nov 01 '17 09:11

Gaurav Vashisth


3 Answers

Simply cleanup the existing jar before running the task again. Running cleandoes work, but it's a little intense in my opinion. Instead, make the android-generated task depend on a very specific cleanup task:

task cleanAndroidMock(type: Delete) {
    description = 'Deletes the mockable Android jar'

    delete fileTree("${project.buildDir}/generated") {
        include 'mockable-android*.jar'
    }
}

project.afterEvaluate {
    tasks['mockableAndroidJar'].dependsOn cleanAndroidMock
}
like image 71
johnmartel Avatar answered Nov 02 '22 01:11

johnmartel


I had this issue. Although, with API 28 platform tools. I deleted from the path and reinstalled, which worked for me.

like image 20
PRAISE ELISHA Avatar answered Nov 02 '22 01:11

PRAISE ELISHA


I have this issue as well as I'm using a modified android.jar (which has all the hidden API revealed). I don't use the unit testing and there's no apparent way to disable it in Android Studio 2.2.2, so I found a workaround for this problem:

Go to File -> Settings -> Build, Execution, Deployment -> Compiler Add to "Command-line Options": -x :app:prepareReleaseUnitTestDependencies -x :app:mockableAndroidJar -x :app:compileReleaseUnitTestSources Press "OK" and try to Rebuild Project again. Now the unit testing compilation tasks will always be skipped and no errors will be thrown.

like image 35
Nawrez Avatar answered Nov 02 '22 01:11

Nawrez