Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Flutter apk always failed using Bitbucket pipeline

Mohammad September 16, 2024

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; }

 

 

2 answers

1 accepted

1 vote
Answer accepted
Mohammad September 19, 2024

Solution  This issue refers into proguard-rules if used inside the app in my case update this file and its work fine  

You find missing's scripts inside mappings directories 

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 18, 2024

Hi Mohammad!

I'm not familiar with flutter, so I can't answer any questions related to that. However, I can give you some context on the environment that Pipelines builds run so you can debug this.

If you run Pipelines builds on Atlassian's infrastructure or with a self-hosted Linux Docker runner, these builds run in Docker containers based on the Docker image you have specified in your bitbucket-pipelines.yml file.

If you have Docker installed on your computer, you can debug a Pipelines build locally with Docker following this guide:

If you follow the steps of the guide, you'll have a clone of the repo at the same commit as the failed build and also use the same Docker image.

You can then debug the issue locally without consuming Pipelines minutes and run additional commands to debug it.

You could also try different Docker images if the one you are using now does not have the version of the tools you need. We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure and self-hosted registries accessible on the internet:

If you run Pipelines builds with a self-hosted Linux Shell, MacOS, or Windows runner, these builds run directly on the host machine using Bash (Linux Shell and MacOS runners) and PowerShell (Windows runners). You can debug these builds outside the runner using Bash or PowerShell respectively.

Please feel free to reach out if you have any questions!

Kind regards,
Theodora

Mohammad September 19, 2024

Thx @Theodora Boudale  😁✋

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2024

You are very welcome! Thank you also for posting the solution!

Like Mohammad likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events