添加google仓库
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() jcenter() } }
添加依赖
dependencies { def lifecycle_version = “2.2.0”
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
... }
Android Architecture Component, AAC
Jetpack 库可以单独使用,也可以组合使用,以满足应用的不同需求。