Repository: flutter
Issue: flutter build appbundle fails due to failing Gradle task signReleaseBundle, but exits 0
Labels: in triage

### Steps to reproduce

1. Have a standard flutter project and try to build a release package, for example:

```shell
flutter build appbundle --build-number 0 --build-name 0.1.2 --release
```
2. Observe gradle `app:signReleaseBundle` fail, for a common reason: not having your key.properties and jks file set up. Note that gradle explicitly tells you it exits with exitcode `1`.

3. Execute `echo $?` and see `0` instead of `1`

### Expected results

I expect a failing child-task exit-code to propagate to flutter. Due to this issue, flutter exits without error even though a child-task (in this case gradle) exits with a non-zero exit status. This causes all kinds of hell with build systems and CI environments.

### Actual results

Parent task exits with non-zero exit code, `flutter build appbundle` exits zero.

### Code sample

This should be occuring with any flutter project, I don't have specific code that causes it; just not having the required key.properties and jks file for Gradle will cause the Gradle signReleaseBundle task to fail, and that should show that flutter in turn obliviously returns 0.

### Screenshots or Video




### Logs


```
[rubin@FRAME app]$ flutter build appbundle --build-number 0 --build-name 1.2.3 --release

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > java.lang.NullPointerException (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 3s
Running Gradle task 'bundleRelease'...                              4.0s
Gradle task bundleRelease failed with exit code 1
```

```
[rubin@FRAME app]$ echo $?
0
```

### Flutter Doctor output

```
[rubin@FRAME app]$ flutter doctor -v
[✓] Flutter (Channel stable, 3.27.2, on Arch Linux 6.12.9-arch1-1, locale en_US.UTF-8)
    • Flutter version 3.27.2 on channel stable at /home/rubin/.local/share/flutterup
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (3 days ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /opt/android
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /opt/android
    • Java binary at: /opt/jetbrains-toolbox/apps/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 19.1.6
    • cmake version 3.31.4
    • ninja version 1.12.1
    • pkg-config version 2.3.0

[✓] Android Studio (version 2024.2)
    • Android Studio at /opt/jetbrains-toolbox/apps/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /opt/jetbrains-toolbox/apps/intellij-idea-ultimate
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Linux (desktop)              • linux         • linux-x64      • Arch Linux 6.12.9-arch1-1
    • Chrome (web)                 • chrome        • web-javascript • Chromium 131.0.6778.264 Arch Linux

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```