Android Studio build fails with “Task '' not found in root project 'MyProject'.”

前端 未结 20 1446
失恋的感觉
失恋的感觉 2020-11-30 02:31

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

相关标签:
20条回答
  • 2020-11-30 03:20

    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.)

    0 讨论(0)
  • 2020-11-30 03:23

    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

    1. Close the current project
    2. File>New>Import Project (Don't use the open recent project)

      Note: I'm sure this kind of error is not on source code when this happened on Import project.
    0 讨论(0)
  • 2020-11-30 03:25

    Problem

    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.

    Investigation

    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.

    Solution

    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!

    0 讨论(0)
  • 2020-11-30 03:28

    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...

    0 讨论(0)
  • 2020-11-30 03:28

    This is what I did

    1. Remove .idea folder

      $ mv .idea .idea.bak

    2. Import the project again

    0 讨论(0)
  • 2020-11-30 03:29

    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.

    0 讨论(0)
提交回复
热议问题