gdelataillade / alarm

A Flutter plugin to easily manage alarms on iOS and Android
https://pub.dev/packages/alarm
MIT License
132 stars 86 forks source link

duplicate class errors with the alarm plugin and Flutter_fgbg #79

Closed Flash0509 closed 1 year ago

Flash0509 commented 1 year ago

alarm 1.2.1

Describe the bug I have big problems with the plugin and get duplicate class errors. There seems to be a conflict between alarm 1.2.1 and Flutter_fgbg

To Reproduce Steps to reproduce the behavior:

  1. just installed alarm 1.2.1

Expected behavior Find a solution for this issue: ERROR: C:\scr\flutter\projects\smartabox_app\build\alarm.transforms\3f03b4caccdeb316d77f1a14c56b987c\transformed\classes\classes.dex: D8: Type com.example.smartabox_app.BuildConfig is defined multiple times: C:\scr\flutter\projects\smartabox_app\build\alarm.transforms\3f03b4caccdeb316d77f1a14c56b987c\transformed\classes\classes.dex, C:\scr\flutter\projects\smartabox_app\build\flutter_fgbg.transforms\259e6456fa506c18132e02beab7ce5be\transformed\classes\classes.dex

Screenshots **

Device info Provide device info (Manufacturer, OS version, ...) Ex: iPhone 13 Pro, iOS 16.2, ...

Provide device info (Manufacturer, OS version, ...) Provide device info (Manufacturer, OS version, ...) Ex: iPhone 13 Pro, iOS 16.2, ...

Additional context Add any other context about the problem here. Ex: iPhone 13 Pro, iOS 16.2, ...

Additional context Add any other context about the problem here. Additional context Add any other context about the problem here.

gdelataillade commented 1 year ago

Hi @Flash0509

Sorry to hear about your issue.

1) Do you use flutter_fgbg in your project ?

2) Have you tried doing:

flutter pub get
flutter clean
flutter run

3) At what moment do you have this error ?

Flash0509 commented 1 year ago

Hi Gautier, thanks for your anwer.

1) Actually, I didn't use flutter_fgbg in my project. But alarm 1.2.1. installed it as an dependency as version 0.2.2.

2) Thousand times

3) When I try flutter run

gdelataillade commented 1 year ago

Thanks for the answer @Flash0509,

I'll try to publish a fix as soon as possible.

In the meantime, please make sure you:

Let me know if it helps. Otherwise, stay tuned and I'll release a fix next week.

Flash0509 commented 1 year ago
  • b thanks for your new respond.

1) Where can I find the README? 2) It is checked, but unfortunaltley the gradle project sync failed with the error:' Task 'wrapper' not found in project ':app'." 3) I tried this and started the command Flutter run, but The error message (duplicate class) is still the same.

gdelataillade commented 1 year ago

README: https://github.com/gdelataillade/alarm/blob/main/README.md

Flash0509 commented 1 year ago

I have some more issues when I activate the alarm related code parts in my app:


final` alarmSettings = AlarmSettings(
          id:42,
          dateTime: scheduledTime,
          assetAudioPath: 'assets/audio/alarm.mp3',
          loopAudio: true,
          vibrate: true,
          volumeMax: true,
          fadeDuration: 3.0,
          notificationTitle: 'Tabletten Erinnerung',
          notificationBody: 'Einnahmezeit für Fach ' + nextCompartmentNumber.toString() +
              ' erreicht. Bitte einnehmen!',
          enableNotificationOnKill: false,
          stopOnNotificationOpen: false);

      await Alarm.set(settings: alarmSettings);

      Alarm.ringStream.stream.listen((_) => checkNextCompartmentTime());

the error message appears, when I started flutter run. The app didn't start.

lib/main.dart:716:23: Error: No named parameter with the name 'settings'. await Alarm.set(settings: alarmSettings); ^^^^^^^^ /C:/Users/gordo/AppData/Local/Pub/Cache/hosted/pub.dev/alarm-1.2.1/lib/alarm.dart:69:23: Context: Found this candidate, but the arguments don't match. static Future set({required AlarmSettings alarmSettings}) async { ^^^ Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

gdelataillade commented 1 year ago

I'm sorry I made a mistake in the README.

Alarm.set parameter name is alarmSettings instead of settings.

Try like this:

await Alarm.set(alarmSettings: alarmSettings);

Flash0509 commented 1 year ago

Okay, code errors are gone, perfect! But of course the duplicate classes issue still exists. I am patiently waiting for your solution next week.

Flash0509 commented 1 year ago

Hello Gautier,

any news concerning my issue?

Thanks in advance.

Kind regards,

Gordon Klein

smarTaBox GmbH | Franz-Liszt-Str. 87 | 14624 Dallgow-Döberitz

Telefon: 0172/3128877

@. @.>

www.smartabox.de http://www.smartabox.de

Von: Gautier de Lataillade @.> Gesendet: Mittwoch, 16. August 2023 23:33 An: gdelataillade/alarm @.> Cc: Flash0509 @.>; Mention @.> Betreff: Re: [gdelataillade/alarm] duplicate class errors with the alarm plugin and Flutter_fgbg (Issue #79)

I'm sorry I made a mistake in the README.

Alarm.set parameter name is alarmSettings instead of settings.

Try like this:

await Alarm.set(alarmSettings: alarmSettings);

— Reply to this email directly, view it on GitHub https://github.com/gdelataillade/alarm/issues/79#issuecomment-1681298228 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BB5GOYHXC6SCGUOHCH5K5HTXVU37LANCNFSM6AAAAAA3RK2YCU . You are receiving this because you were mentioned. https://github.com/notifications/beacon/BB5GOYANEZEZZH7XS64UVYTXVU37LA5CNFSM6AAAAAA3RK2YCWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTEG2JTI.gif Message ID: @. @.> >

gdelataillade commented 1 year ago

Hi @Flash0509

I was never able to reproduce your error. It seems like you are the only one. That means the issue comes probably from your project.

I asked ChatGPT what to do in your case, here's his answer:

Flutter Duplicate Class Error Solution

The error indicates that the BuildConfig class for your com.example.smartabox_app package is defined multiple times, typically resulting from conflicting dependencies or plugins in a Flutter project.

From your details, it's evident that both your main app and the alarm plugin use the flutter_fgbg plugin, leading to duplicate class definitions.

Solutions:

1) Exclude Modules in Build:

If using Gradle, you can exclude specific modules to avoid duplicate class definitions:

implementation ('com.example:alarm:1.0.0') {
    exclude group: 'com.example', module: 'flutter_fgbg'
}

2) Use Dependency Resolution Strategies:

Define a resolution strategy in your app's android/build.gradle:

configurations.all {
    resolutionStrategy {
        force 'com.example:flutter_fgbg:1.0.0' // replace with actual group:module:version
    }
}

This ensures only the specified version of flutter_fgbg is utilized.

3) Check for Unused Dependencies:

Review your dependencies. Remove any that are no longer in use to reduce potential future conflicts.

4) Clean and Rebuild:

Post changes, clean the build directory and rebuild:

flutter clean
flutter run

Please let me know if it works or if you still have an issue.