[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Add components to your project\n\n[Issue Tracker](https://issuetracker.google.com/issues/new?component=197448&template=878802)\n\nReport issues so we can fix bugs.\n\nBefore getting started, read the\n[Guide to app architecture](/topic/architecture) for useful principles that\napply to all Android apps and for guidance on\nusing architecture components together.\n\nArchitecture components are available from Google's Maven repository. To use\nthem, add the repository to your project.\n\nOpen the `settings.gradle` file and add the `google()` repository: \n\n### Groovy\n\n```groovy\ndependencyResolutionManagement {\n ...\n repositories {\n google()\n jcenter()\n }\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencyResolutionManagement {\n ...\n repositories {\n google()\n jcenter()\n }\n}\n```\n| **Warning:** The JCenter repository is read-only, as of March 31, 2021. For more information, see [JCenter service update](/studio/build/jcenter-migration).\n\nDeclare dependencies\n--------------------\n\nOpen the `build.gradle` file for your app or module and add the artifacts\nthat you need as dependencies. You can add dependencies for all architecture\ncomponents or choose a subset.\n\nSee the instructions for declaring dependencies for each architecture component in the release notes:\n\n- [Futures (found in androidx.concurrent)](/jetpack/androidx/releases/concurrent)\n- [Lifecycle (including ViewModel)](/jetpack/androidx/releases/lifecycle)\n- [Navigation (including SafeArgs)](/jetpack/androidx/releases/navigation)\n- [Paging](/jetpack/androidx/releases/paging)\n- [Room](/jetpack/androidx/releases/room)\n- [WorkManager](/jetpack/androidx/releases/work)\n\nSee [AndroidX releases](/jetpack/androidx/versions) for the most up-to-date\nversion numbers for each component.\n\nFor more information about the AndroidX refactor and how it affects these class\npackages and module IDs, see [Migrate to AndroidX](/jetpack/androidx/migrate).\n\nKotlin\n------\n\nKotlin extension modules are supported for several AndroidX dependencies. These\nmodules have the suffix `-ktx` appended to their names. For example: \n\n### Groovy\n\n```groovy\nimplementation \"androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version\"\n```\n\n### Kotlin\n\n```kotlin\nimplementation(\"androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version\")\n```\n\nbecomes \n\n### Groovy\n\n```groovy\nimplementation \"androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version\"\n```\n\n### Kotlin\n\n```kotlin\nimplementation(\"androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version\")\n```\n\nMore information, including docs for Kotlin extensions, can be found in the\n[KTX documentation](/kotlin/ktx).\n\n**Note:** For Kotlin based apps, make sure you use\n`kapt` instead of `annotationProcessor`. You should also\nadd the `kotlin-kapt` plugin.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [App Architecture: UI Layer - Get Started - Android Developers](/topic/libraries/data-binding/start)\n- [Work with observable data objects](/topic/libraries/data-binding/observability)\n- [Migrate from Kotlin synthetics to Jetpack view binding](/topic/libraries/view-binding/migration)"]]