Gradle: FAILURE: Could not determine which tasks to execute

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

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.