I get this error when trying to build my project after changing laptop and updating to Android Studio version 0.8.2.
FAILURE: Build failed with an exc
I got this error when switching from one Git branch to another, and then trying to run "Clean Project". I used ack
to search for the Task name, and found it in a .iml file.
My solution was to regenerate the project's .iml file by clicking (in the main menu) Tools > Android > Sync Project with Gradle Files. (Thanks to this answer.)
Apparently this issue caused by Android Studio on the various situation but the reason is build error When importing an existing project into android studio.
In my case, I've imported my exist project where I was supposed to install few build tools then finally build configuration was done with error. In this case, just do the following things
I specifically got the "[module_name]:prepareDebugUnitTestDependencies" task not found
error, every time I ran gradle build. This happened to me after updating my Android Studio to 3.0.0.
I had previously added command-line options to the gradle-based compiler, which you can find under: File -> Settings -> Build, Execution, Deployment -> Compiler -> Command-line Options. Specifically, I had excluded a number of tasks, including the aforementioned task. While that worked fine on the previous stable version (2.3 at that time), it seems like this was the reason behind the build failure.
This is one of many possible solutions. Make sure you have the correct command-line options specified in the settings under: File -> Settings -> Build, Execution, Deployment -> Compiler -> Command-line Options, and that none of them is causing this problem.
In my case, I removed the exclusion of this task (and other tasks that seemed related), left the unrelated tasks excluded, and it worked!
Yet another solution to the same problem:
This happened to me every time I imported an eclipse project into studio using the wizard (studio version 1.3.2).
What I found, quite by chance, was that quitting out of Android studio and then restarting studio again made the problem go away.
Frustrating, but hope this helps someone...
This is what I did
Remove .idea folder
$ mv .idea .idea.bak
Import the project again
This happened to me recently when I close one Android Studio project and imported another Eclipse project. It seemed to be some bug in Android Studio where it preserves some gradle settings from previously open project and then get confused in the new project.
The solution was extremely simple: Close the project and shut down Android Studio completely, before re-opening it and then import/open the new project. Everything goes smoothly from then on.