內容目錄

build.gradle

buildscript {
    ext.nav_version = "2.5.3"
    ext.lifecycle_version = "2.5.1"
    ext.preference_version = "1.2.0"
    ext.room_version = "2.5.0"
    ext.work_version = "2.8.0"
    ext.coroutines_version = "1.6.3"

    ext.dexter_version = "6.2.2"
    ext.glide_version = "4.13.2"
    dependencies {
        // for fragment safe args
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    }
}
...

app/build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    // for fragment safe args
    id 'androidx.navigation.safeargs.kotlin'
    // for room
    id 'kotlin-kapt'
}

android {
    ...
    packagingOptions {
        exclude 'META-INF/atomicfu.kotlin_module'
    }
    buildFeatures {
        viewBinding true
        dataBinding true
    }
}

dependencies {
    ...
    
    // RecyclerView
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "androidx.cardview:cardview:1.0.0"

    // fragment navigation component
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

    // preference
    implementation "androidx.preference:preference:$preference_version"

    // Lifecycle components
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"

    // Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

    // WorkManager
    implementation "androidx.work:work-runtime-ktx:$work_version"

    // Room
    implementation "androidx.room:room-runtime:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    // dexter
    implementation "com.karumi:dexter:$dexter_version"

    // glide
    implementation "com.github.bumptech.glide:glide:$glide_version"
    annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"

    // OkHttp3
    implementation "com.squareup.okhttp3:okhttp:4.10.0"
    implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
    implementation "com.squareup.retrofit2:adapter-rxjava3:2.9.0"

		
    ...
}

Reference

最新的 androidx 函式庫版本

Last modified: 2023 年 2 月 22 日

Author

Comments

Write a Reply or Comment

Your email address will not be published.