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

🐞Type 'WorkmanagerPlugin' has no member 'registerBGProcessingTask' and Type 'WorkmanagerPlugin' has no member 'registerPeriodicTask' #551

Open
4 tasks done
Brechard opened this issue Apr 24, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@Brechard
Copy link

Brechard commented Apr 24, 2024

  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.5.2
Xcode version 15.3
Swift version 5.10
iOS deployment target 12

Describe the error

I was following the setup for iOs and when reaching the "You MUST amend your AppDelegate.swift and Info.plist file to register your task ID." I receive those errors in Xcode.

I have cloned this repo and the same errors show on the example (on the flutter side there are 4 errors like: error: The method 'registerProcessingTask' isn't defined for the type 'Workmanager'. (undefined_method at [workmanager_example] lib/main.dart:266)

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
• Flutter version 3.19.6 on channel stable at ~/software/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (7 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at ~/Library/Android/sdk
• Platform android-34, 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.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.2)
• 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.9+0-17.0.9b1087.7-11185874)

[✓] 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)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• 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

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

[✓] Connected device (4 available)
• Pixel 8 (mobile) • 39011FDJH007KM • android-arm64 • Android 14 (API 34)
• iPhone 15 Pro (mobile) • 195714BD-9F6E-47A9-9886-313A3A97FC68 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.62

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

@Brechard Brechard added the bug Something isn't working label Apr 24, 2024
@Cmk427
Copy link

Cmk427 commented Apr 25, 2024

You may try to change the branch of the package in pubspec.yaml file:

  workmanager:
    git:
      url: https://github.com/absar/flutter_workmanager.git
      ref: ios-bg-tasks-enh-final

It may help you to solve your issue at this moment.

@joonne
Copy link

joonne commented May 7, 2024

The above solution seems to work, I'm now able to build the app and triggering the background task from the debugger works. Could we get a comment whether this is the "correct" solution for making this plugin work on iOS at the moment?

@nk4n01
Copy link

nk4n01 commented May 8, 2024

I got the same error !!

@razumeiko
Copy link

Don't you think that it's weird? The official git link is https://github.com/fluttercommunity/flutter_workmanager
but you are pulling code from https://github.com/absar/flutter_workmanager.git who knows what he could code there.

@joonne
Copy link

joonne commented May 10, 2024

I could have elaborated a bit, those changes from https://github.com/absar/flutter_workmanager.git are actually in main already and waiting to be released: b783000 👍

(or that is how I understood the situation)

@dario-digregorio
Copy link

dario-digregorio commented May 16, 2024

I spend too much time figuring out why the described setup is not working with my project until I realized that the link to the iOS Setup brings you to the GitHub Repo, has a different version than the one that is published on pub.dev 🥲
So for others that are struggling use the right version in your pubspec.yml and read the Readme's from that commit b783000.

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

@Kurokirisu
Copy link

Kurokirisu commented May 21, 2024

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

I am now using this version instead of the 0.5.2 version and at first it worked fine, but now I get an error on Android:

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

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.0-runtime (androidx.work:work-runtime-ktx:2.7.0)
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.0-runtime (androidx.work:work-runtime-ktx:2.7.0)

I really need the periodic tasks to work on iOS, so I hope someone can help me with this since they don't work in the 0.5.2 version.

@ghufrankhan
Copy link

Pubspec

  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager.git
      ref: b783000

I am now using this version instead of the 0.5.2 version and at first it worked fine, but now I get an error on Android:

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

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.0-runtime (androidx.work:work-runtime-ktx:2.7.0)
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.0-runtime (androidx.work:work-runtime-ktx:2.7.0)

I really need the periodic tasks to work on iOS, so I hope someone can help me with this since they don't work in the 0.5.2 version.

Hi, try adding this line inside the dependencies array found in /android/app/build.gradle:

implementation("androidx.work:work-runtime-ktx:2.8.1")

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

8 participants