2015-06-13 46 views
0

Gradle在終端中給出了以下錯誤。Gradle:無法將任務':helloFromBuild1'添加爲具有該名稱的任務

* What went wrong: 
A problem occurred evaluating script. 
> Cannot add task ':helloFromBuild1' as a task with that name already exists. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 
+0

您需要提供更多上下文來解決此問題。你的構建腳本是怎樣的? –

+0

@ Rene,請看我的答案。 – charany1

回答

1

任務名稱衝突可能是由於不正確地導入文件導致的。有關更好的解釋,請參閱此文章Gradle : Cannot add task ‘:helloFromBuild1’ as a task with that name already exists.

一個從上述鏈接的解決方案非常小摘錄低於:

解決方案:

如果你想同時導入build_1.gradle的任務,並在build_3 build_2.gradle 。 gradle,然後在上面的情況下,只能通過 在build_3.gradle中導入build_2.gradle來完成,因爲build_1.gradle中已包含 build_1.gradle任務。

+0

只需鏈接到您自己的庫(或實用程序)不是一個好的答案。鏈接到它,解釋爲什麼它解決了這個問題,提供代碼使用它來解決這個問題,並放棄更好的答案。請參閱:[如何以社區友好的方式鏈接到外部資源?](https://meta.stackexchange.com/questions/94022/) – Drew

相關問題