This documentation shows how to add dependencies for Androidx Activity API. There it mentions androidx.activity:activity-ktx:$activity_version to be declared. In my project, only Androidx dependencies that I have declared are appcompat, core, lifecycle, constraintlayout and recyclerview. But still in my project I am able to use androidx.activity.result.contracts.ActivityResultContracts. How is this possible?
EDIT: I commented out all 3rd party dependencies and now, my entire dependencies section is as follows:
dependencies {
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
// Materials design
implementation("com.google.android.material:material:1.4.0")
implementation("androidx.appcompat:appcompat:1.3.1")
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.0")
val lifecycleVersion = "2.4.0-alpha03"
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
}
Still I am able to import any androidx.* library in my project.
CodePudding user response:
androidx.appcompat:appcompat:1.3.1 depends on androidx.activity:activity:1.2.4.
So your implementation("androidx.appcompat:appcompat:1.3.1") line pulls in androidx.activity:activity:1.2.4 via the transitive dependency.
