Gradle 构建失败 - Android Studio 4.0

Gradle build failed - Android Studio 4.0

我正在尝试向 android 工作室打开一个旧项目,出现此 Gradle 错误

Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

如 gradle 错误所述:

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)

按照以下步骤操作:

  • 关闭 Android Studio 并为

    终止 Android Studio 的所有进程
    • Mac => 按 Command + Option + Esc 然后强制停止 Android Studio
    • 的进程
    • Windows => Ctrl + Alt + Del 键盘快捷键并单击任务管理器,然后单击更多详细信息按钮以显示所有 运行 进程。
  • 运行 Android 再次工作室

  • 确保您有有效且有效的互联网连接,然后再次尝试构建您的项目