I don't know how you can import previous dependency settings from other project into new project. Is it a function of Android Studio?
But I think print the whole dependency tree will solve your confusion, because some dependencies maybe be implicit included by directly declared dependencies.
You can open terminal and execute ./gradlew dependencies
to print all dependencies of the whole project.
See https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html for more details.
I tried and found this,
debugRuntimeClasspath - Runtime classpath of compilation 'debug' (target (androidJvm)).
+--- androidx.compose.ui:ui-tooling:1.1.1
| +--- androidx.annotation:annotation:1.1.0 -> 1.3.
| +--- androidx.compose.runtime:runtime:1.1.1
| |
| |
...
| \--- androidx.activity:activity-compose:1.3.0 -> 1.4.0
| +--- androidx.compose.runtime:runtime:1.0.1 -> 1.1.1 (*)
| +--- androidx.compose.runtime:runtime-saveable:1.0.1 -> 1.1.1 (*)
| +--- androidx.activity:activity-ktx:1.4.0
...
It tells us that androidx.activity:activity-ktx:1.4.0
is imported by androidx.activity:activity-compose:1.3.0
, and androidx.activity:activity-compose:1.3.0
is imported by androidx.compose.ui:ui-tooling:1.1.1
.
You can find the androidx.compose.ui:ui-tooling:1.1.1
is declared in app's build.gradle
. Link
Then, you can find the activity-compose
import activity-ktx
by using api
following this link.
About the api
's meaning in build.gradle
, please refer to this.
So project architecture-samples can use viewModels()
without implementation
the dependency activity-ktx
in build.gradle
.