Gradle 3.3版不支持 BuildActionExecter 上的 forTask()方法

我刚把我的 Android Studio 升级到了3.0金丝雀1。 现在我正致力于我现有的 Android Studio 3.0金丝雀1项目。 默认情况下,级别: 3.0.0-alpha1在我的项目中设置: gradle _ file。 所以我把我的等级版本改成了2.2.3,现在我得到了这个错误:

错误: 未能完成 Gradle 的执行。

原因: 您正在使用的 Gradle (3.3)版本不支持 BuildActionExecter 上的 forTasks ()方法 可在 Gradle 3.5和所有更高版本中使用。

我把我的档案附在这里

// 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
}
77964 次浏览

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

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.

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
}

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

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

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

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.

Only Change the gradle URL to

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

as follow image :

enter image description here

  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

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