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

谁说我不能喝 提交于 2019-12-05 04:25:32

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
}

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.

Try going to menu: Build -> Clean Project.
Or you can try menu: Files -> Invalidade Caches/Restart
Both worked for me!

Easiest solution is to navigate to the given path [[...]/build/generated/mockable-android-27.v3.jar] and simply remove the file mockable-android-27.v3.jar.Go back to android studio and build again.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!