Error:FAILURE: Build failed with an exception. * What went wrong: Task '' not found in root projec

在使用Android studio的過程中,用gradle assembleRelease編譯版本的時候,出現下列錯誤,無法編譯


Error:FAILURE: Build failed with an exception.
* What went wrong:
Task '' not found in root project ''.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

在網上找了好多方法,有兩種說法最多的:

   1.直接在項目的目錄下修改與項目名稱同名的.iml文件,刪除<component name="FacetManager"> ... </component>,這個方法試過,沒什麼卵用!

   2.在用mv命令移除方法:mv .idea .idea.bak    然後Import the project again   這種方法我沒沒試過 ;


   3.最後在stack overflow論壇的亂花從中發現一句話(紅色的字體是關鍵):

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.

也就是說,解決的方法很簡單,就是關閉項目並且完全關閉Android Studio這個軟件,然後打開一個新項目import/open the new project,然後就正常了。經本人測試,方法有效。






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章