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

前端 未结 20 1532
失恋的感觉
失恋的感觉 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: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!

提交回复
热议问题