Skip to content

Duplicate class androidx.work.OneTimeWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.1-runtime (androidx.work:work-runtime-ktx:2.7.1) #299

Description

@k0psutin

What happened?

I noticed that if I use home_widget: ^0.7.0 with workmanager: ^0.5.2 it will give a duplicate class exception during build, removing home_widget: ^0.7.0 resolves this issue.

My dependencies:

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  flutter_riverpod: ^2.1.3
  go_router: ^14.2.8
  dio: ^5.0.0
  easy_localization: ^3.0.1
  flutter_svg: ^2.0.7
  firebase_remote_config: ^5.1.3
  firebase_analytics: ^11.3.3
  fl_chart: ^0.69.0
  table_calendar: ^3.0.8
  flutter_local_notifications: ^17.0.1
  localstore: ^1.3.5
  timezone: ^0.9.2
  flutter_timezone: ^3.0.1
  freezed_annotation: ^2.4.1
  collection: ^1.17.0
  firebase_core: ^3.6.0
  firebase_messaging: ^15.1.3
  url_launcher: ^6.1.11
  shared_preferences: ^2.2.0
  permission_handler: ^11.0.0
  intl: ^0.19.0
  connectivity_plus: ^6.0.2
  flutter_native_splash: ^2.3.2
  expandable: ^5.0.1
  flutter_keyboard_visibility: ^6.0.0
  ua_client_hints: ^1.1.3
  android_alarm_manager_plus: ^4.0.2
  package_info_plus: ^8.0.2
  home_widget: ^0.7.0
  workmanager: ^0.5.2

It seems that at the home_widget example, there is a implementation "androidx.work:work-runtime-ktx:2.8.1" in build.gradle.

After I added the same implementation, the build finally passed. I think the README should be updated to inform that the user should implement the same work-runtime-ktx as in the example? Or is it possible to fix home_widget so that the user don't have to determine the version?

How to reproduce:

Remove implementation "androidx.work:work-runtime-ktx:2.8.1" from example build.gradle

What do you expect?

Build to complete

Relevant log output

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkStagingDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class androidx.work.OneTimeWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.1-runtime (androidx.work:work-runtime-ktx:2.7.1)
     Duplicate class androidx.work.PeriodicWorkRequestKt found in modules work-runtime-2.8.1-runtime (androidx.work:work-runtime:2.8.1) and work-runtime-ktx-2.7.1-runtime (androidx.work:work-runtime-ktx:2.7.1)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 10s
Error: Gradle task assembleStagingDebug failed with exit code 1

Exited (1).

Execute in a terminal and put output into the code block below

[✓] Flutter (Channel stable, 3.24.3, on macOS 13.6.7 22G720 darwin-arm64, locale en-FI)
• Flutter version 3.24.3 on channel stable at /Users/xxxx/fvm/versions/3.24.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184aa7 (2 weeks ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/xxxx/Library/Android/sdk
• Platform android-34-ext11, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.93.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.96.0

[✓] Connected device (4 available)
• 2109119DG (mobile) • 40a26781 • android-arm64 • Android 14 (API 34)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.6.7 22G720 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 13.6.7 22G720 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.70

[✓] Network resources
• All expected network resources are available.

• No issues found!

On which Platform do you experience this issue?

Android

Other information

Add implementation "androidx.work:work-runtime-ktx:2.8.1" to build.gradle dependencies and it will build again. I hope it doesn't have any side-effects for other packages.

Are you interested in working on a PR for this?

  • I want to work on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions