'Dart snapshot generator failed with exit code -9

Debugging mode working well but when I tried to run it as release mode or building apk it's not working. Tried all things that I could but it's not working (Create a new project shift it). Other projects working well.

[✓] Flutter (Channel stable, 2.10.5, on Archcraft 5.17.4-arch1-1, locale
    en_US.UTF-8)
    • Flutter version 2.10.5 at /var/lib/flutter
    • Framework revision 5464c5bac7 (11 days ago), 2022-04-18 09:55:37
      -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version
    33.0.0-rc1)
    • Platform android-31, build-tools 33.0.0-rc1
    • Java version OpenJDK Runtime Environment (build
      11.0.13+0-b1751.21-8125866)


• No issues found!



[+243312 ms] Dart snapshot generator failed with exit code -9
[+1191 ms] > Task :app:compileFlutterBuildRelease FAILED
[ +895 ms] FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script '/var/lib/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildRelease'.
[        ] > Process 'command '/var/lib/flutter/bin/flutter'' finished with non-zero exit value 1
[        ] * 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.
[   +8 ms] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 6m 15s
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
[        ] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
[        ] See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
[        ] 342 actionable tasks: 326 executed, 16 up-to-date
[+1586 ms] Running Gradle task 'assembleRelease'... (completed in 377.7s)
[  +17 ms] Exception: Gradle task assembleRelease failed with exit code 1
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:400:9)
           <asynchronous suspension>
           #2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:179:5)
           <asynchronous suspension>


[        ] exiting with code 1


Solution 1:[1]

I have solved the problem. It was my mistake in code. I have a that I convert SVG to flutter Custompainter FlutterShapeMaker. This was more than 3Klines long and for some reason, it was stopping the build. After removing everything I was able to build the app for release.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 monzim