Fixing the “Failed to Transform FishBun-0.11.2.aar” Error in Flutter

Posted by

If you’ve been working with Flutter and encountered the dreaded Failed to transform FishBun-0.11.2.aar error while building your app, you’re not alone. This issue typically arises when using certain outdated or conflicting dependencies, which result in Gradle failing to resolve files or transform artifacts.

In this blog post, I’ll walk you through the steps to identify the cause of this error and provide a straightforward solution.


Understanding the Error

Here’s the full error message you might see in your console:

Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform FishBun-0.11.2.aar (com.sangcomz:FishBun:0.11.2) to match attributes {artifactType=android-assets, org.gradle.category=library, ...}.
     > Could not find FishBun-0.11.2.aar (com.sangcomz:FishBun:0.11.2).
       Searched in the following locations:
       https://jcenter.bintray.com/com/sangcomz/FishBun/0.11.2/FishBun-0.11.2.aar

This issue occurs because the FishBun library and its dependencies were hosted on JCenter, which has been deprecated and is no longer available.


Steps to Fix the Error

1. Identify the Problematic Dependency

The core problem is the dependency multi_image_picker (or its newer version, multi_image_picker2), which internally relies on the outdated FishBun library.

2. Analyze Your pubspec.yaml File

If you’re using either multi_image_picker or multi_image_picker2, you’ll need to comment out or remove them to eliminate this error. These packages are no longer actively maintained and can cause compatibility issues.

Here’s an example of a problematic pubspec.yaml configuration before the fix:

dependencies:
  permission_handler: ^11.0.1
  dropdown_search: ^5.0.6
  multi_image_picker: ^4.8.0
  # multi_image_picker2: ^5.0.02
  numberpicker: ^2.0.1

3. Remove or Replace the Dependency

You can fix the issue by commenting out multi_image_picker and multi_image_picker2 like this:

dependencies:
  permission_handler: ^11.0.1
  dropdown_search: ^5.0.6
  # multi_image_picker: ^4.8.0
  # multi_image_picker2: ^5.0.02
  numberpicker: ^2.0.1

4. Clean and Rebuild the Project

After making these changes, run the following commands to clean and rebuild your project:

flutter clean
flutter pub get
flutter run

Why Does This Work?

By removing the multi_image_picker package, you effectively remove the dependency on FishBun, which relies on JCenter. Since JCenter is deprecated, Gradle fails to locate the necessary files, leading to the build error. Commenting out or replacing the outdated package resolves the issue.


Recommended Alternatives

If you need to use a package for selecting multiple images, consider using these actively maintained alternatives:

  • ImagePicker: The official Flutter plugin for picking images and videos from the gallery or camera.
  • FilePicker: A versatile plugin for picking any type of file, including images.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x