gradle > 任务:app:externalNativeBuildDebug 失败 android_gradle_build.json(没有这样的文件或目录)

gradle > Task :app:externalNativeBuildDebug FAILED android_gradle_build.json (No such file or directory)

我正在尝试使用

从命令行构建一个 android 项目
./gradlew app:assembleDebug

然而,当我构建任务失败时:

> Task :app:externalNativeBuildDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> java.io.FileNotFoundException: /Users/hcwiley/MyProject/app/.externalNativeBuild/cmake/debug/arm64-v8a/android_gradle_build.json (No such file or directory)

如果我 运行 Sync Project with Gradle Files 在 Android Studio 中它可以解决问题。

我如何从命令行执行此操作,这样我就不必为此基本操作启动 Android Studio?

另请注意,在较新版本的 Gradle 中 .externalNativeBuild 已被替换 .cxx

我已经试过这些都无济于事:

rm -rf app/.externalNativeBuild app/build
./gradlew cleanBuildCache
./gradlew clean

我的gradle/wrapper/gradle-wrapper.properties:

#Mon Oct 07 16:53:24 CDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

尝试使用 --rerun-tasks 命令行参数重新运行所有任务。这将强制 Gradle 到 运行 所有任务,同时忽略最新检查。 来自 Gradle docs:

This will force test [...or in your case, app] and all task dependencies of test to execute. It’s a little like running gradle clean test, but without the build’s generated output being deleted.