Android - 使用 Gradle 将构建输出复制到另一个文件夹

Android - Copy build output to another folder with Gradle

我正在尝试在 Visual Studio App Center 上构建我的 React Native Android 应用程序,但我收到此错误:

Task         : Shell script
Description  : Run a shell script using Bash
Version      : 2.165.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/shell-script
==============================================================================
[command]/bin/bash /Users/runner/runners/2.165.2/scripts/android-postprocess.sh /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk
Removing all ABI or density dependent APKs…
find: /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk: No such file or directory
find: /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk: No such file or directory
find: /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk: No such file or directory
Found        0 APK file(s)
Found        0 unaligned APK file(s)
find: /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk: No such file or directory
/Users/runner/runners/2.165.2/scripts/android-postprocess.sh: line 36: pushd: /Users/runner/runners/2.165.2/work/1/s/mobile/android/app/app/build/outputs/apk/..: No such file or directory
/Users/runner/runners/2.165.2/scripts/android-postprocess.sh: line 43: popd: directory stack empty

##[error]The process '/bin/bash' failed with exit code 1
##[error]Bash failed with error: The process '/bin/bash' failed with exit code 1
##[section]Finishing: Android Postprocess
##[section]Starting: Post Build Script

它错误地在 app/app/build/... 而不是 app/build/... 中查找我的 APK 所以我想将文件复制到 app/app/build/.. 所以它在那里找到它们。

我无法使用 post-build 脚本复制文件,因为它在引发错误的脚本之后运行。

是否可以通过 Gradle 以某种方式实现复制?或者可能有多个构建路径?或者其他一些解决方案?

问题是我的 app 模块文件夹中有 gradlewgradlew.batgradle 文件夹。我一定是在 Android Studio 中错误地单独打开了 app 文件夹并同步了项目。
我通过创建一个新的 React Native 项目解决了这个问题。