Skip to content

Failure to build on Android when host app includes [firebase_core] and [firebase_messaging] dependencies #7

@MuhammadEssam96

Description

@MuhammadEssam96

🐛 card_flutter fails to build on Android when host app includes firebase_core and firebase_messaging

Description

When integrating card_flutter into a Flutter app that uses firebase_core and firebase_messaging, the Android build fails due to a duplicate class error.

The error also occurs when building the bundled example app after adding these Firebase dependencies.


Steps to Reproduce

  1. Create a new Flutter app or use the provided example app in card_flutter.
  2. Add the following dependencies to pubspec.yaml:
    dependencies:
      firebase_core: ^2.30.0
      firebase_messaging: ^14.7.10
  3. Run flutter pub get.
  4. Build the app for Android:
    flutter build apk --flavor qa --debug

Actual Result

Build fails with the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkQaReleaseDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules firebase-iid-20.1.5.aar (com.google.firebase:firebase-iid:20.1.5) 
     and firebase-messaging-24.1.1.aar (com.google.firebase:firebase-messaging:24.1.1)

     Learn how to fix dependency resolution errors at https://d.android.com/r/tools/classpath-sync-errors

Expected Result

The app should build successfully with card_flutter, firebase_core, and firebase_messaging dependencies included.


Notes

  • The issue appears to be caused by an outdated or conflicting transitive Firebase dependency.
  • A resolution strategy or exclusion rule might be needed in card_flutter's build.gradle to avoid pulling in deprecated Firebase libraries (like firebase-iid).

Please look into resolving this compatibility issue or provide guidance on an official workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions