Library module doesn't include dependencies in Android

I am working on a multi-module project and this project should have a Java Library module called test-shared to provide common test classes. However, I am facing an issue in which my module doesn't recognize dependencies and I cannot write my classes.

Things have been done

  1. Enable offline mode and disable again.
  2. Delete .gradle folder and sync.
  3. Googled identical issues.
  4. Invalidate cache & restart.

As a result, I don't have a working project. Your help would be welcome.

build.gradle

apply plugin: 'java-library'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2"
    implementation "androidx.test:rules:1.2.0"
    implementation "androidx.lifecycle:lifecycle-runtime:2.1.0"
    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.1.0"
}

sourceCompatibility = "8"
targetCompatibility = "8"

Example class

class Co {

    val a = LiveData<Co>()
    val b = Observer<Co>()
}

In this example, neither LiveData nor Observer are recognized. Could you please help me fix this weird issue?

Thanks,

1 answer