How do I import androidx.work.WorkManager?
Asked Answered
K

2

9

Can't import androidx.work.WorkManager. Working with Studio 3.4

enter image description here

Kurtzig answered 10/2, 2020 at 17:10 Comment(2)
have u added in your dependenciesFulbert
What dependencies do I have to add? Already done this(gradle.properties): android.useAndroidX=true android.enableJetifier=trueMoo
F
17

Just add this and it should work. in your dependencies block in build.gradle at app level.

dependencies {
     //other dependencies
     //......
    implementation "androidx.work:work-runtime:2.3.1"
}
Fulbert answered 10/2, 2020 at 17:21 Comment(0)
D
5

You first need to add the work manager dependency in your app's build.gradle file within the dependencies block like this:

dependencies {
  def work_version = "2.3.1"

    // (Java only)
    implementation "androidx.work:work-runtime:$work_version"

    // Kotlin + coroutines
    implementation "androidx.work:work-runtime-ktx:$work_version"

    // optional - RxJava2 support
    implementation "androidx.work:work-rxjava2:$work_version"

    // optional - GCMNetworkManager support
    implementation "androidx.work:work-gcm:$work_version"

    // optional - Test helpers
    androidTestImplementation "androidx.work:work-testing:$work_version"
  }

(source)

Just use the one you need and feel free to omit the optionals. Then you would be able to import it in your classes/activities. If not Clear your caches and sync your project with the gradle files and try again.

Dispense answered 10/2, 2020 at 17:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.