问题
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
}
回答1:
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
回答2:
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.
回答3:
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
回答4:
Please follow the below steps:
- Open your project in android studio
- In Android menu, open gradle-wrapper.properties
- Change the distribution url line with the below line
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
- Thats it. Build your project now.
Screenshot is attached for more understanding.
回答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
回答6:
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
}
回答7:
We have two way to deal with it.
You can update your gradle's version from the early one to 3.5 version product;
Or,you can figure your gradle wrapper to 4.1 version.
All of the ways are both useful.
回答8:
Only Change the gradle URL to
"distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip"
as follow image :
回答9:
- Open gradle-wrapper.properties
Replace:
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
With:
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
- Now sync project
Click here for more understand
回答10:
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
来源:https://stackoverflow.com/questions/44206433/gradle-version-3-3-does-not-support-fortask-method-on-buildactionexecuter