Gradle: FAILURE: Could not determine which tasks t

2020-02-03 06:18发布

Upgraded to Android Studio 0.2.0 and got the following error. The error got resolved after applying suggested solution but now the following error appeared.

Gradle: 
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assemble' not found in root project 'MerlinCheckProject'.
* Try:
Run gradle tasks to get a list of available tasks.

I have no clue what the error is how to solve it. Appreciate help.

6条回答
干净又极端
2楼-- · 2020-02-03 06:38

Inspired by the answer from @Dhafer.Dhib to check the installed gradle version, I want to add: The recommended way to install gradle under linux is using sdk, see https://gradle.org, I did the following steps:

sudo apt install zip    ## zip required by SDKman, see http://sdkman.io/
## do the following steps as the user who wants to use the tools NOT root!
curl -s "https://get.sdkman.io" | bash    ## SDKman recommended option to install *up-to-date* gradle, see https://gradle.org/install/
source "/root/.sdkman/bin/sdkman-init.sh"     ## set env to use sdk without opening a new shell
sdk install gradle 4.6
gradle -v
查看更多
smile是对你的礼貌
3楼-- · 2020-02-03 06:45

The solution works fine. If you're having issues with it, ensure you close Android Studio completely, then edit the file, then reopen it.

查看更多
Melony?
4楼-- · 2020-02-03 06:47

Remove <component name="FacetManager"> ... </component> from your iml file.


From http://tools.android.com/knownissues:

If you get the following error message:

Gradle: FAILURE: Could not determine which tasks to execute.

  • What went wrong: Task 'assemble' not found in root project 'MyProject'.

  • Try: Run gradle tasks to get a list of available tasks.

The real problem is that previous version of Android Studio misconfigured the IDEA file (e.g. MyProject.iml) -- it added an extra <component name="FacetManager"> XML element that shouldn't be present. In the case above, the solution is to edit MyProject.iml and to remove the <component name="FacetManager"> part as shown here:

<?xml version="1.0" encoding="UTF-8"?>
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    ...remove this element and everything inside such as <facet> elements...
  </component>
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    ...keep this part...
  </component>
</module>

Alternatively you could remove the project's .idea folder and iml files and re-import your sources into a new Android Studio project.

In the next release we'll fix this -- there will be a "fix this" button to do that fix automatically for you.

查看更多
Anthone
5楼-- · 2020-02-03 06:59

In my case, in a cordova project, I had an old gradle version 1.4 and that was the problem. So try to remove gradle

sudo apt-get remove gradle

then, download new binary relase of gradle from here . I got v3.5.1. Finally, Create a directory for the Gradle installation.

sudo mkdir /opt/gradle

Extract the downloaded archive to the newly created directory.

sudo unzip -d /opt/gradle gradle-3.5.1-bin.zip

Configure the PATH environment variable so that the gradle executable can be directly executed anywhere on the system.

export PATH=$PATH:/opt/gradle/gradle-3.5.1/bin

You can run the following command to check if the Gradle install was successful.

gradle -v
查看更多
够拽才男人
6楼-- · 2020-02-03 07:01

Deleting the facet-manager component from IML file did not solve the problem for me. I got the same error and closing and reopening the project caused the facet-manager component to be recreated in the iml file.

I had to delete the .idea directory and the .iml file and then import the top level gradle.build file to solve the problem. I was able to import the project in place using the import option on the initial Android Studio menu (with no project open).

查看更多
干净又极端
7楼-- · 2020-02-03 07:01

I am a Windows user. The solution that worked for me was to remove the previous version of Android Studio:

http://developer.android.com/sdk/installing/studio.html#Updating

查看更多
登录 后发表回答