111

I just updated my Android Studio to 3.0 canary 1. Now I am working on my existing project on Android Studio 3.0 canary 1. By default gradle:3.0.0-alpha1 is set in my project: gradle_file. So I changed my gradle version to 2.2.3 and now I'm getting this error:

Error:Failed to complete Gradle execution.

Cause: The version of Gradle you are using (3.3) does not support the forTasks() method on BuildActionExecuter. Support for this is available in Gradle 3.5 and all later versions.

I attached my gradle file here

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Erowlin
  • 9,555
  • 4
  • 35
  • 63
Ajay Jayendran
  • 1,584
  • 4
  • 15
  • 37
  • 5
    Can anyone suggest how can you fix these without having to update gradle version and android plugin version? Because doing so requires a lot of other changes which we can not do because of some business constraints. – Sasuke Uchiha Nov 06 '17 at 06:15

10 Answers10

196

I've just had the same issue. Fixed it by changing Gradle distributionUrl in "gradle-wrapper.properties".

Here is what I have configured:

#Wed Mar 22 16:13:58 BRT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

for more details

Offical video to help migaration https://www.youtube.com/watch?v=oBsbI8ICYKg

see also comment below from @TmTron

falico
  • 1,974
  • 1
  • 13
  • 8
  • 19
    For anyone wanting to know the latest distribution, go to the directory https://services.gradle.org/distributions. All of them are listed – I.G. Pascual Jun 14 '17 at 20:12
  • 4
    Please read @I.G.Pascual comment before changing to the specific version, because you could just update the version to the newest version currently available. When this comment posted, the current release is 4.0(stable). So it is safe if you change to `distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip` – HendraWD Jun 15 '17 at 10:26
  • 4
    Just take care when you open a multi-module application: Android Studio may only show you one gradle-wrapper properties fiel in the Project-Android view. to make sure to change everything, use *Find in Path* (CTRL+SHIFT+F) and search for *distributionUrl*. – TmTron Aug 10 '17 at 09:54
  • I also faced same issue with below error `Cause: The version of Gradle you are using (3.3) does not support the forTasks() method on BuildActionExecuter. Support for this is available in Gradle 3.5 and all later versions.` So i have updated gradle-wrapper.properties file for `distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip` – ViramP Oct 16 '17 at 06:32
  • 1
    Thank you for your heads-up, @TmTron, that was my problem. falico, if you don't mind, I think it would be beneficial to highlight TmTron's comment in your answer above. – BareMetalCoder Dec 15 '17 at 19:34
65

Change in the file "gradle-wrapper.properties".

Put this line and Sync Project-

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

This will work. For Check latest version services.gradle.org/distributions

After changed, Sync Project, Clean and Rebuild project once from Build menu.

Kailas Bhakade
  • 1,902
  • 22
  • 27
  • 4
    Check https://services.gradle.org/distributions before you changing to specific version, because you could just update the version to the latest version currently available. When this comment posted, the current release is 4.0(stable). So it is safe if you change to `distributionUrl=https\://services.gradle.org/distributions/g‌​radle-4.0-all.zip`, because it is more stable than `milestone-1` version – HendraWD Jun 15 '17 at 10:30
  • Yes, You are right, always prefer stable version than other. But still you can use it. @HendraWD Thank for comment. – Kailas Bhakade Jun 16 '17 at 09:15
  • Updating Android Studio from 2.3 to 3.0, Check official guidelines from https://www.youtube.com/watch?v=oBsbI8ICYKg – Kailas Bhakade Nov 01 '17 at 12:48
28

This happened when trying to build debug apk.

SOLUTION: Update Gradle version to 3.5

Navigate to File -> Project Structure -> Project -> Gradle Version = 3.5

This works for Android Studio 3.0

this is the image of the menu where you have to make the change

JonathanDavidArndt
  • 2,518
  • 13
  • 37
  • 49
Paixols
  • 448
  • 6
  • 10
  • This is the solution for the ones that intentionally does not want to upgrade to gradle 4. – ram Dec 21 '17 at 17:52
  • It doesn't. It upgrades to Gradle Version 3.5, the minimum for the functionality that he wants to use. – Quinton M. Jan 23 '18 at 14:56
14

Please follow the below steps:

  1. Open your project in android studio
  2. In Android menu, open gradle-wrapper.properties
  3. Change the distribution url line with the below line

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip

  1. Thats it. Build your project now.

Screenshot is attached for more understanding. enter image description here

Naveed Ahmad
  • 6,627
  • 2
  • 58
  • 83
5

I resolved the issue by changinf distributionUrl in the following code in gradle-wrapper.properties file

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Saurabh Singh
  • 1,241
  • 13
  • 11
2

Once add these with Top level Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha9'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
ViramP
  • 1,659
  • 11
  • 11
1

We have two way to deal with it.

  1. You can update your gradle's version from the early one to 3.5 version product;

  2. Or,you can figure your gradle wrapper to 4.1 version.

All of the ways are both useful.

Benchur Wong
  • 2,377
  • 2
  • 9
  • 13
1

Only Change the gradle URL to

"distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip"

as follow image :

enter image description here

Osama Ibrahim
  • 995
  • 10
  • 13
0
  1. Open gradle-wrapper.properties
  2. Replace:

    distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

With:

distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
  1. Now sync project

Click here for more understand

Wajid khan
  • 842
  • 9
  • 18
0

put this code in gradle-wrapper.properties file and it will work with you

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Ahmed Mohamed
  • 301
  • 1
  • 12