Search code examples
androidkotlindependencieskotlin-coroutines

What’s the use of the coroutines dependencies on an Android app?


My question is what’s the use of the coroutines dependencies on an Android app?

Specifically the following dependency that is mentioned in the Android Developers site

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'

(or the newer version 1.6.4)

Seems to me that everything that is related to coroutines, works fine even without this dependency. So what is the purpose of adding this dependency to an Android project?

The rest of the dependencies of the Android project

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.recyclerview:recyclerview:1.3.0-alpha02"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Solution

  • Just for your information: coroutines are already included in libraries:

    
    dependencies {
        implementation('androidx.appcompat:appcompat:1.5.1'){
            exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm'
            exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-android'
            exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core'
        }
        //implementation 'com.google.android.material:material:1.7.0' <- include coroutines
        //implementation 'androidx.constraintlayout:constraintlayout:2.1.4' <- include coroutines
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.4'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
    }
    

    That's why you see and can use coroutines features.