重要
maven仓库快照仓库地址
maven { url('https://s01.oss.sonatype.org/content/repositories/snapshots/') } 复制代码
compose基础库依赖
implementation 'io.github.ananananzhuo-blog:composelib:1.0.19' 复制代码
==
implementation 'io.github.ananananzhuo-blog:composelib:1.0.20-SNAPSHOT' 复制代码
mvvm基础库依赖
implementation 'io.github.ananananzhuo-blog:mvvmlib:1.0.8' 复制代码
==
implementation 'io.github.ananananzhuo-blog:mvvmlib:1.0.16-SNAPSHOT' 复制代码
kotlin扩展库
implementation 'io.github.anhorseg:androidexthorse:1.0.1' 复制代码
汇总一些常用依赖
androidx 对 viewmodel 的扩展程序
androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 复制代码
androidx 对 lifecycle 的扩展程序
implementation('androidx.lifecycle:lifecycle-runtime-ktx:2.2.0') 复制代码
androidx 对 livedata 的扩展程序
androidx.lifecycle:lifecycle-livedata-ktx:2.2.0 复制代码
Core KTX
implementation "androidx.core:core-ktx:1.3.1" 复制代码
Collection KTX
implementation "androidx.collection:collection-ktx:1.1.0" 复制代码
Navigation KTX
implementation "androidx.navigation:navigation-runtime-ktx:2.3.0" implementation "androidx.navigation:navigation-fragment-ktx:2.3.0" implementation "androidx.navigation:navigation-ui-ktx:2.3.0" 复制代码
Room KTX
implementation "androidx.room:room-ktx:2.2.5" 复制代码
SQLite KTX
implementation "androidx.sqlite:sqlite-ktx:2.1.0" 复制代码
WorkManager KTX
implementation "androidx.work:work-runtime-ktx:2.4.0" 复制代码
SavedStateHandle 的使用
android { dataBinding.enabled = true ... } dependencies { implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' } 复制代码
Room 持久性库的使用
dependencies { def room_version = "2.2.5" implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version" // For Kotlin use kapt instead of annotationProcessor // optional - Kotlin Extensions and Coroutines support for Room implementation "androidx.room:room-ktx:$room_version" // optional - RxJava support for Room implementation "androidx.room:room-rxjava2:$room_version" // optional - Guava support for Room, including Optional and ListenableFuture implementation "androidx.room:room-guava:$room_version" // Test helpers testImplementation "androidx.room:room-testing:$room_version" } 复制代码
添加 Navigation 支持
dependencies { def nav_version = "2.3.0" // Java language implementation implementation "androidx.navigation:navigation-fragment:$nav_version" implementation "androidx.navigation:navigation-ui:$nav_version" // Kotlin implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" // Feature module Support implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version" // Testing Navigation androidTestImplementation "androidx.navigation:navigation-testing:$nav_version" } 复制代码
Paging 组件
dependencies { def paging_version = "2.1.2" implementation "androidx.paging:paging-runtime:$paging_version" // For Kotlin use paging-runtime-ktx // alternatively - without Android dependencies for testing testImplementation "androidx.paging:paging-common:$paging_version" // For Kotlin use paging-common-ktx // optional - RxJava support implementation "androidx.paging:paging-rxjava2:$paging_version" // For Kotlin use paging-rxjava2-ktx } 复制代码
协程依赖插件
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" 复制代码
RecyclerView 的依赖项
implementation "androidx.recyclerview:recyclerview:1.1.0" // For control over item selection of both touch and mouse driven selection implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" 复制代码
Compose导航依赖
2.4.0-alpha02版本
implementation("androidx.navigation:navigation-compose:2.4.0-alpha02") 复制代码
2.4.0-alpha03版本
implementation("androidx.navigation:navigation-compose:2.4.0-alpha03") 复制代码
该版本对应的gradle依赖如下:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" 复制代码
Activity fragment扩展库,可以使用LifecycleScope,这两个库最好一起使用
implementation 'androidx.activity:activity-ktx:1.3.0' implementation 'androidx.fragment:fragment-ktx:1.3.0' 复制代码
Compose使用Paging3
implementation "androidx.paging:paging-runtime:3.0.0-beta02" implementation "androidx.paging:paging-compose:1.0.0-alpha08" 复制代码
Compose中SwipeRefresh的使用
implementation ("com.google.accompanist:accompanist-swiperefresh:0.18.0") 复制代码
compose中的Banner库
implementation "com.google.accompanist:accompanist-pager:0.16.1" 复制代码
需要添加阿里云仓库
maven { allowInsecureProtocol = true url "http://maven.aliyun.com/nexus/content/groups/public" } 复制代码
okhttp和retrofit
implementation "com.squareup.retrofit2:retrofit:2.4.0" implementation "com.squareup.retrofit2:converter-gson:2.4.0" implementation "com.squareup.okhttp3:okhttp:3.10.0" implementation "com.squareup.okhttp3:logging-interceptor:3.10.0" 复制代码
compose状态栏和底部导航栏颜色处理依赖库
implementation "com.google.accompanist:accompanist-insets:0.16.0" implementation "com.google.accompanist:accompanist-systemuicontroller:0.16.0" 复制代码
业务性很强的依赖
官方的ImageView形状处理ShapeImageView
implementation 'com.google.android.material:material:1.2.1' 复制代码
郭霖的权限依赖
比较干净的一个库
dependencies { implementation 'com.permissionx.guolindev:permissionx:1.4.0'} 复制代码
使用方法参考:blog.csdn.net/guolin_blog…
zxing扫码库
需要引入的代码量极少,拿来可以直接用。有自定义需求可以将CaptureActivity拿出来自己修改
implementation('com.github.shenyuanqing.zxing:zxing-simplify:1.0.5') 复制代码
使用参考:blog.csdn.net/shenyuanqin…
compose中ViewModel扩展库的使用
一般我们的项目到会导入导航库,会自动带上这个库,如果写demo不引入导航库,就需要手动导入这个库来使用ViewMOdel的扩展功能
implementation("androidx.navigation:navigation-compose:2.4.0-alpha02")