I am trying to build a flutter app using google Cloud Build, I am constantly getting this error 1: [+1000 ms] FAILURE: Build failed with an exception. 1: [ ] * Where: 1: [ ] Script '/opt/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102 1: [ ] * What went wrong: 1: [ ] Execution failed for task ':app:compileFlutterBuildRelease'. 1: [ ] > Process 'command '/opt/flutter/bin/flutter'' finished with non-zero exit value 1 1: [ ] * Try: 1: [ ] 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. 1: [ ] * Get more help at https://help.gradle.org 1: [ ] BUILD FAILED in 11m 45s

NOTE: I've already tried flutter clean, flutter pub get, flutter pub update, flutter pub outdated etc etc

here is the whole log, when I ran it with: flutter build appbundle --verbose

starting build "ebf4440b-fcfa-49d3-82e2-148aa9b2d75e"

FETCHSOURCE
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/buildtrial-1/r/bitbucket_XXX_XXXX
* branch            5d16aea43c6f0b4e29046a8db33d3495bd816a00 -> FETCH_HEAD
HEAD is now at 5d16aea cb1111
BUILD
Starting Step #0
Step #0: Already have image (with digest): gcr.io/cloud-builders/git
Step #0: Cloning into 'parkoncloud'...
Finished Step #0
Starting 1
1: Pulling image: gcr.io/buildtrial-1/flutter
1: Using default tag: latest
1: latest: Pulling from buildtrial-1/flutter
1: 88736512a147: Pulling fs layer
1: a0c7e8a778bb: Pulling fs layer
1: 5aef8d1d5cc4: Pulling fs layer
1: 975e2ab8701d: Pulling fs layer
1: 64935c7b5706: Pulling fs layer
1: 270f69dfa524: Pulling fs layer
1: af122c03d3d8: Pulling fs layer
1: 5cb7f32fa58a: Pulling fs layer
1: ad1014aafb12: Pulling fs layer
1: ea20d7d49b21: Pulling fs layer
1: ac9d387f4881: Pulling fs layer
1: d6312a945051: Pulling fs layer
1: e7edb74ca408: Pulling fs layer
1: 10cd9f19207b: Pulling fs layer
1: 65838a12a534: Pulling fs layer
1: f29fb1a859a5: Pulling fs layer
1: 8ca0202e0c3f: Pulling fs layer
1: 64935c7b5706: Waiting
1: 270f69dfa524: Waiting
1: af122c03d3d8: Waiting
1: 5cb7f32fa58a: Waiting
1: ad1014aafb12: Waiting
1: ea20d7d49b21: Waiting
1: 975e2ab8701d: Waiting
1: ac9d387f4881: Waiting
1: d6312a945051: Waiting
1: e7edb74ca408: Waiting
1: 10cd9f19207b: Waiting
1: 65838a12a534: Waiting
1: f29fb1a859a5: Waiting
1: 8ca0202e0c3f: Waiting
1: 88736512a147: Download complete
1: a0c7e8a778bb: Verifying Checksum
1: a0c7e8a778bb: Download complete
1: 975e2ab8701d: Verifying Checksum
1: 975e2ab8701d: Download complete
1: 64935c7b5706: Verifying Checksum
1: 64935c7b5706: Download complete
1: 270f69dfa524: Verifying Checksum
1: 270f69dfa524: Download complete
1: af122c03d3d8: Verifying Checksum
1: af122c03d3d8: Download complete
1: ad1014aafb12: Download complete
1: ea20d7d49b21: Verifying Checksum
1: ea20d7d49b21: Download complete
1: ac9d387f4881: Verifying Checksum
1: ac9d387f4881: Download complete
1: 5aef8d1d5cc4: Verifying Checksum
1: 5aef8d1d5cc4: Download complete
1: d6312a945051: Verifying Checksum
1: d6312a945051: Download complete
1: e7edb74ca408: Verifying Checksum
1: e7edb74ca408: Download complete
1: 65838a12a534: Verifying Checksum
1: 65838a12a534: Download complete
1: f29fb1a859a5: Verifying Checksum
1: f29fb1a859a5: Download complete
1: 8ca0202e0c3f: Verifying Checksum
1: 8ca0202e0c3f: Download complete
1: 5cb7f32fa58a: Verifying Checksum
1: 5cb7f32fa58a: Download complete
1: 88736512a147: Pull complete
1: a0c7e8a778bb: Pull complete
1: 10cd9f19207b: Verifying Checksum
1: 10cd9f19207b: Download complete
1: 5aef8d1d5cc4: Pull complete
1: 975e2ab8701d: Pull complete
1: 64935c7b5706: Pull complete
1: 270f69dfa524: Pull complete
1: af122c03d3d8: Pull complete
1: 5cb7f32fa58a: Pull complete
1: ad1014aafb12: Pull complete
1: ea20d7d49b21: Pull complete
1: ac9d387f4881: Pull complete
1: d6312a945051: Pull complete
1: e7edb74ca408: Pull complete
1: 10cd9f19207b: Pull complete
1: 65838a12a534: Pull complete
1: f29fb1a859a5: Pull complete
1: 8ca0202e0c3f: Pull complete
1: Digest: sha256:18a545ad8e421d245f4bb18ce784a3056822d7f59c88a773afd60257dff14b63
1: Status: Downloaded newer image for gcr.io/buildtrial-1/flutter:latest
1: gcr.io/buildtrial-1/flutter:latest
1: fatal: No names found, cannot describe anything.
1: 
1:   â•‘                 Welcome to Flutter! - https://flutter.dev                  â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ The Flutter tool uses Google Analytics to anonymously report feature usage â•‘
1:   â•‘ statistics and basic crash reports. This data is used to help improve      â•‘
1:   â•‘ Flutter tools over time.                                                   â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ Flutter tool analytics are not sent on the very first run. To disable      â•‘
1:   â•‘ reporting, type 'flutter config --no-analytics'. To display the current    â•‘
1:   â•‘ setting, type 'flutter config'. If you opt out of analytics, an opt-out    â•‘
1:   â•‘ event will be sent, and then no further information will be sent by the    â•‘
1:   â•‘ Flutter tool.                                                              â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ By downloading the Flutter SDK, you agree to the Google Terms of Service.  â•‘
1:   â•‘ Note: The Google Privacy Policy describes how data is handled in this      â•‘
1:   â•‘ service.                                                                   â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ Moreover, Flutter includes the Dart SDK, which may send usage metrics and  â•‘
1:   â•‘ crash reports to Google.                                                   â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ Read about data we send with crash reports:                                â•‘
1:   â•‘ https://flutter.dev/docs/reference/crash-reporting                         â•‘
1:   â•‘                                                                            â•‘
1:   â•‘ See Google's privacy policy:                                               â•‘
1:   â•‘ https://policies.google.com/privacy                                        â•‘ 1: 
1: [✓] Flutter (Channel stable, 2.10.5, on Ubuntu 18.04.6 LTS 5.10.0-12-cloud-amd64, locale en_US)
1:     • Flutter version 2.10.5 at /opt/flutter
1:     • Upstream repository https://github.com/flutter/flutter
1:     • Framework revision 5464c5bac7 (4 days ago), 2022-04-18 09:55:37 -0700
1:     • Engine revision 57d3bac3dd
1:     • Dart version 2.16.2
1:     • DevTools version 2.9.2
1: 
1: [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
1:     • Android SDK at /opt/android_sdk
1:     • Platform android-32, build-tools 30.0.3
1:     • ANDROID_HOME = /opt/android_sdk
1:     • Java binary at: /usr/bin/java
1:     • Java version OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.18.04)
1:     • All Android licenses accepted.
1: 
1: [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
1:     ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
1: 
1: [!] Android Studio (not installed)
1:     • Android Studio not found; download from https://developer.android.com/studio/index.html
1:       (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
1: 
1: [!] Connected device
1:     ! No devices available
1: 
1: [✓] HTTP Host Availability
1:     • All required HTTP hosts are available
1: 
1: ! Doctor found issues in 3 categories.
1: Running "flutter pub get" in workspace...                         297.7s
1: [  +89 ms] executing: uname -m
1: [ +169 ms] Exit code 0 from: uname -m
1: [   +1 ms] x86_64
1: [   +7 ms] executing: [/opt/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
1: [   +4 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
1: [        ] 5464c5bac742001448fe4fc0597be939379f88ea
1: [   +1 ms] executing: [/opt/flutter/] git tag --points-at 5464c5bac742001448fe4fc0597be939379f88ea
1: [  +16 ms] Exit code 0 from: git tag --points-at 5464c5bac742001448fe4fc0597be939379f88ea
1: [        ] 2.10.5
1: [  +11 ms] executing: [/opt/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
1: [   +4 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
1: [        ] origin/stable
1: [        ] executing: [/opt/flutter/] git ls-remote --get-url origin
1: [   +3 ms] Exit code 0 from: git ls-remote --get-url origin
1: [        ] https://github.com/flutter/flutter
1: [ +202 ms] executing: [/opt/flutter/] git rev-parse --abbrev-ref HEAD
1: [   +4 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
1: [        ] stable
1: [   +1 ms] Found plugin sqflite at /builder/home/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.2+1/
1: [   +6 ms] Found plugin url_launcher at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.20/
1: [   +1 ms] Found plugin url_launcher_android at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_android-6.0.15/
1: [        ] Found plugin url_launcher_ios at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.15/
1: [        ] Found plugin url_launcher_linux at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-3.0.0/
1: [        ] Found plugin url_launcher_macos at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-3.0.0/
1: [        ] Found plugin url_launcher_web at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.9/
1: [        ] Found plugin url_launcher_windows at /builder/home/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-3.0.0/
1: [   +1 ms] Found plugin wc_flutter_share at /builder/home/.pub-cache/hosted/pub.dartlang.org/wc_flutter_share-0.4.0/
1: [  +22 ms] Generating /workspace/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
1: [ +224 ms] 💪 Building with sound null safety 💪
1: [  +29 ms] Running Gradle task 'bundleRelease'...
1: [  +15 ms] Using gradle from /workspace/android/gradlew.
1: [  +14 ms] executing: [/workspace/android/] /workspace/android/gradlew -Pverbose=true -Ptarget-platform=android-arm,android-arm64,android-x64 -Ptarget=lib/main.dart -Pbase-application-name=android.app.Application -Pdart-obfuscation=false -Ptrack-widget-creation=true -Ptree-shake-icons=true bundleRelease
1: [ +519 ms] Downloading https://services.gradle.org/distributions/gradle-7.1.1-all.zip
1: [+7241 ms] .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
1: [ +130 ms] Unzipping /root/.gradle/wrapper/dists/gradle-7.1.1-all/1wqbeia0d49252rmlcr6o8lbl/gradle-7.1.1-all.zip to /root/.gradle/wrapper/dists/gradle-7.1.1-all/1wqbeia0d49252rmlcr6o8lbl
1: [+5778 ms] Set executable permissions for: /root/.gradle/wrapper/dists/gradle-7.1.1-all/1wqbeia0d49252rmlcr6o8lbl/gradle-7.1.1/bin/gradle
1: [+1342 ms] Welcome to Gradle 7.1.1!
1: [        ] Here are the highlights of this release:
1: [        ]  - Faster incremental Java compilation
1: [        ]  - Easier source set configuration in the Kotlin DSL
1: [ +128 ms] For more details see https://docs.gradle.org/7.1.1/release-notes.html
1: [ +364 ms] Starting a Gradle Daemon (subsequent builds will be faster)
1: [+415925 ms] Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
1: [        ] License for package Android SDK Platform 28 accepted.
1: [        ] Preparing "Install Android SDK Platform 28 (revision: 6)".
1: [+9924 ms] "Install Android SDK Platform 28 (revision: 6)" ready.
1: [        ] Installing Android SDK Platform 28 in /opt/android_sdk/platforms/android-28
1: [        ] "Install Android SDK Platform 28 (revision: 6)" complete.
1: [  +73 ms] "Install Android SDK Platform 28 (revision: 6)" finished.
1: [+4958 ms] > Task :app:preBuild UP-TO-DATE
1: [ +493 ms] > Task :app:extractProguardFiles
1: [        ] > Task :app:preReleaseBuild
1: [  +44 ms] > Task :app:writeReleaseApplicationId
1: [ +205 ms] > Task :app:analyticsRecordingRelease
1: [        ] > Task :app:cleanMergeReleaseAssets UP-TO-DATE
1: [  +92 ms] > Task :app:mergeReleaseShaders
1: [        ] > Task :app:compileReleaseShaders NO-SOURCE
1: [        ] > Task :app:generateReleaseAssets UP-TO-DATE
1: [+30004 ms] > Task :app:compileFlutterBuildRelease
1: [+181164 ms] > Task :app:compileFlutterBuildRelease FAILED
1: [+1000 ms] FAILURE: Build failed with an exception.
1: [        ] * Where:
1: [        ] Script '/opt/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102
1: [        ] * What went wrong:
1: [        ] Execution failed for task ':app:compileFlutterBuildRelease'.
1: [        ] > Process 'command '/opt/flutter/bin/flutter'' finished with non-zero exit value 1
1: [        ] * Try:
1: [        ] 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.
1: [        ] * Get more help at https://help.gradle.org
1: [        ] BUILD FAILED in 11m 45s
1: [        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
1: [        ] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
1: [        ] See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
1: [        ] 6 actionable tasks: 5 executed, 1 up-to-date
1: [+1364 ms] Running Gradle task 'bundleRelease'... (completed in 707.6s)
1: [   +2 ms] [!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
1: [   +6 ms] Running Gradle task 'bundleRelease'...
1: [   +6 ms] Using gradle from /workspace/android/gradlew.
1: [  +64 ms] executing: [/workspace/android/] /workspace/android/gradlew -Pverbose=true -Ptarget-platform=android-arm,android-arm64,android-x64 -Ptarget=lib/main.dart -Pbase-application-name=android.app.Application -Pdart-obfuscation=false -Ptrack-widget-creation=true -Ptree-shake-icons=true bundleRelease
1: [+22314 ms] Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
1: [   +6 ms] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
1: [        ] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
1: [        ] Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
1: [+7578 ms] > Task :app:preBuild UP-TO-DATE
1: [ +154 ms] > Task :app:extractProguardFiles UP-TO-DATE
1: [  +32 ms] > Task :app:preReleaseBuild UP-TO-DATE
1: [        ] > Task :app:writeReleaseApplicationId UP-TO-DATE
1: [        ] > Task :app:analyticsRecordingRelease
1: [ +216 ms] > Task :app:cleanMergeReleaseAssets UP-TO-DATE
1: [   +2 ms] > Task :app:mergeReleaseShaders UP-TO-DATE
1: [        ] > Task :app:compileReleaseShaders NO-SOURCE
1: [        ] > Task :app:generateReleaseAssets UP-TO-DATE
1: [+30006 ms] > Task :app:compileFlutterBuildRelease
1: [+250772 ms] > Task :app:compileFlutterBuildRelease FAILED
1: [ +598 ms] FAILURE: Build failed with an exception.
1: [        ] * Where:
1: [        ] Script '/opt/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102
1: [        ] * What went wrong:
1: [        ] Execution failed for task ':app:compileFlutterBuildRelease'.
1: [        ] > Process 'command '/opt/flutter/bin/flutter'' finished with non-zero exit value 1
1: [        ] * Try:
1: [        ] 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.
1: [        ] * Get more help at https://help.gradle.org
1: [ +198 ms] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
1: [        ] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
1: [        ] See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
1: [        ] 6 actionable tasks: 2 executed, 4 up-to-date
1: [        ] BUILD FAILED in 5m 11s
1: [ +610 ms] Running Gradle task 'bundleRelease'... (completed in 312.6s)
1: [   +5 ms] "flutter appbundle" took 1,022,656ms.
1: [   +5 ms] Gradle task bundleRelease failed with exit code 1
1: [        ] 
1:            #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
1:            #1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:400:9)
1:            <asynchronous suspension>
1:            #2      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:416:15)
1:            <asynchronous suspension>
1:            #3      AndroidGradleBuilder.buildAab (package:flutter_tools/src/android/gradle.dart:197:5)
1:            <asynchronous suspension>
1:            #4      BuildAppBundleCommand.runCommand (package:flutter_tools/src/commands/build_appbundle.dart:156:5)
1:            <asynchronous suspension>
1:            #5      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
1:            <asynchronous suspension>
1:            #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
1:            <asynchronous suspension>
1:            #7      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
1:            <asynchronous suspension>
1:            #8      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
1:            <asynchronous suspension>
1:            #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
1:            <asynchronous suspension>
1:            10     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
1:            <asynchronous suspension>
1:            11     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
1:            <asynchronous suspension>
1:            12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
1:            <asynchronous suspension>
1:            13     main (package:flutter_tools/executable.dart:94:3)
1:            <asynchronous suspension>
1: 
1: 
1: [   +5 ms] ensureAnalyticsSent: 3ms
1: [   +1 ms] Running shutdown hooks
1: [        ] Shutdown hooks complete
1: [        ] exiting with code 1
Finished 1
ERROR
ERROR: build 1 "gcr.io/buildtrial-1/flutter" failed: step exited with non-zero status: 1


Solution 1: RAHUL BHARADWAJ

I figured out a solution.

Ours was a very large application and the default computational power assigned by google Cloud Build(VM with 4 GB RAM) wasn't enough, I had to bump it up to 8 GB RAM and it worked.