I'm encountering a build failure while running the flutter build apk command as part of my Bitbucket pipeline. The build process is failing due to issues with the Gradle shrinker, resulting in the following error message:
- What could be causing the shrinker to fail in this environment, and how can I resolve it without completely disabling it?
- Are there any known issues with Gradle, shrinker, or Flutter in Bitbucket Pipelines that could be contributing to this problem?
- Would upgrading or downgrading certain Gradle versions help in this situation?
Build Failed in 12m 32s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/8.0/userguide/command_line_interface.html#sec:command_line_warnings 882 actionable tasks: 881 executed, 1 up-to-date Some file system contents retained in the virtual file system are on file systems that Gradle doesn't support watching. The relevant state was discarded to ensure changes to these locations are properly detected. You can override this by explicitly enabling file system watching.
Running Gradle task 'assembleRelease'... (completed in 753.0s)
Flutter Fix
[!] The shrinker may have failed to optimize the Java bytecode. To disable the shrinker, pass the `--no-shrink` flag to this command. To learn more, see: https://developer.android.com/studio/build/shrink-code
Here are the last few lines of the log:
"flutter apk" took 755,487ms. 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:544:7) #2 AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:224:5) #3 BuildApkCommand.runCommand (package:flutter_tools/src/commands/build_apk.dart:141:5) #4 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1408:27) #5 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) #6 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #7 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:420:9)
Build Script
- export PATH="$PATH:/sdks/flutter/bin"
- flutter clean
- GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa" flutter pub get
- flutter build apk --verbose || { echo "Build failed"; exit 1; }