OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
614 stars 212 forks source link

[Error] Duplicate class com.google.firebase.components.AbstractComponentContainer found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) #455

Closed Kalela closed 2 years ago

Kalela commented 3 years ago

I am trying to set up OneSignal for push notifications on Android. The app wont launch when I have learning_text_recognition: ^0.0.2 Google ML Kit dependency in my pubspec.yaml along with onesignal_flutter(null safety). If the ML Kit dependency is removed it launches fine.

Environment OneSignal Flutter SDK: ^3.0.0 Flutter SDK: ">=2.12.0 <3.0.0" ANDROID: 10 pubspec.yaml snippet

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  learning_text_recognition: ^0.0.2
  onesignal_flutter: ^3.0.0
  flutter:
    sdk: flutter

Steps to Reproduce Issue:

  1. Create a new flutter app.
  2. Install the OneSignal Flutter SDK for android by following OneSignal SDK set up.
  3. Add learning_text_recognition: ^0.0.2 into you dependencies in pubspec.yaml. (Copy pubspec.yaml file above)
  4. Run the app

FAILURE: Build failed with an exception.

Duplicate class com.google.firebase.components.CycleDetector$1 found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.CycleDetector$ComponentNode found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.CycleDetector$Dep found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.Dependency found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.DependencyCycleException found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.DependencyException found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0) Duplicate class com.google.firebase.components.EventBus found in modules jetified-firebase-common-18.0.0-runtime (com.google.firebase:firebase-common:18.0.0) and jetified-firebase-components-16.0.0-runtime (com.google.firebase:firebase-components:16.0.0)

emawby commented 3 years ago

@Kalela Thank you for the report. It appears that our gradle plugin is causing the version of firebase-messaging to be selected as 19.0.0 instead of 22.0.0 for some build configurations. We are working on a fix for this, but in the meantime you can manually resolve the issue by adding the following to the build.gradle file for the android-onesignal_flutter module in the dependencies section. implementation 'com.google.firebase:firebase-messaging:22.0.0'

It should look like this

dependencies {
    api 'com.onesignal:OneSignal:4.4.1'
    implementation 'com.google.firebase:firebase-messaging:22.0.0'
}