Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
k0psutin opened this issue Sep 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@k0psutin
Copy link

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
@k0psutin k0psutin added the bug Something isn't working label Sep 27, 2024
@Sesa1988
Copy link

Sesa1988 commented Oct 1, 2024

I have the same issue with XML and Glance Widgets but when I add the work-runtime to build.gradle, I get the following tested with XML widgets:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

Not sure if this has something to do with the migration of build.gradle to the latest non imperative version. I could not make any widget work because of these errors.

@csarigumba
Copy link

Bumping this since facing the same issue. What should be the correct fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants