在Android Studio 3.0版本下开发时碰到的一个奇怪问题,Make Project可以通过,然而Build APK却提示错误:
Error:Failed to complete Gradle execution.
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.
尝试过按提示手动升级Gradle版本到3.5,并且Clean project 和 Rebuild project 都没有解决这个问题。查找后StackOverflow有解决方案:
1、切换AS左侧的项目结构视图为Android
2、修改Gradle Script目录下的gradle-wrapper.properties文件
将最后一行:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
修改为
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
改完后sync now,问题解决,正常打包apk,保险起见可以clean一下。