Android開(kāi)發(fā)教程——jetpack的一些依賴(lài),建議收藏?。。?/h2>

導(dǎo)航

  dependencies {
        def activity_version = "1.2.0-rc01"

    // Java language implementation
    implementation "androidx.activity:activity:$activity_version"
    // Kotlin
    implementation "androidx.activity:activity-ktx:$activity_version"

    implementation "androidx.fragment:fragment:1.3.0-rc01"

    implementation "androidx.fragment:fragment-ktx:1.3.0-rc01"
    }

在1.2版本之后舍棄了之前的startActivityForResult而采用ActivityResult Api

dependencies {
  def nav_version = "2.3.2"

  // 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"

  // Jetpack Compose Integration
  implementation "androidx.navigation:navigation-compose:1.0.0-alpha04"
}


生物識(shí)別以及身份認(rèn)證

dependencies {
    // Java language implementation
    implementation "androidx.biometric:biometric:1.0.1"

    // Kotlin
    implementation "androidx.biometric:biometric:1.2.0-alpha01"
  }


由于并非所有的設(shè)備都會(huì)有生物識(shí)別的硬件,所以需要不同情況不同分析。
相機(jī)
--

dependencies {
  // CameraX core library using the camera2 implementation
  def camerax_version = "1.0.0-rc01"
  // The following line is optional, as the core library is included indirectly by camera-camera2
  implementation "androidx.camera:camera-core:${camerax_version}"
  implementation "androidx.camera:camera-camera2:${camerax_version}"
  // If you want to additionally use the CameraX Lifecycle library
  implementation "androidx.camera:camera-lifecycle:${camerax_version}"
  // If you want to additionally use the CameraX View class
  implementation "androidx.camera:camera-view:1.0.0-alpha20"
  // If you want to additionally use the CameraX Extensions library
  implementation "androidx.camera:camera-extensions:1.0.0-alpha20"
}

一些依賴(lài)

implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.constraintlayout:constraintlayout:2.0.0"
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
api "androidx.multidex:multidex:2.0.1"
kapt 'androidx.annotation:annotation:1.2.0'
api "com.google.android.material:material:1.3.0"


//動(dòng)畫(huà)差值器
implementation "androidx.interpolator:interpolator:1.0.0"
//app startup
implementation "androidx.startup:startup-runtime:1.0.0"
//一個(gè)庫(kù)開(kāi)發(fā)者,并且使用了ContentProvider的方式來(lái)進(jìn)行初始化操作,那么你應(yīng)該接入App Startup,這樣可以讓接入你的庫(kù)的App降低啟動(dòng)耗時(shí)。

//讀取和寫(xiě)入圖片文件 EXIF 標(biāo)記。
 implementation "androidx.exifinterface:exifinterface:1.3.2"

//查看文件文檔
implementation "androidx.documentfile:documentfile:1.0.1"

//下拉刷新
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

//viewpager2
implementation "androidx.viewpager2:viewpager2:1.0.0"
//兼容window,以折疊屏為目標(biāo)
implementation "androidx.window:window:1.0.0-alpha01"
//web
implementation "androidx.webkit:webkit:1.4.0"

//側(cè)滑窗口
implementation "androidx.slidingpanelayout:slidingpanelayout:1.1.0"


dependencies {
    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-rc03"
}

//降低現(xiàn)有和新的小型集合對(duì)內(nèi)存的影響。
dependencies {
        def collection_version = "1.1.0"

        // Java language implementation
        implementation "androidx.collection:collection:$collection_version"
        // Kotlin
        implementation "androidx.collection:collection-ktx:$collection_version"
    }
    
    
    
dependencies {
    def core_version = "1.3.2"

    // Java language implementation
    implementation "androidx.core:core:$core_version"
    // Kotlin
    implementation "androidx.core:core-ktx:$core_version"

    // To use RoleManagerCompat
    implementation "androidx.core:core-role:1.0.0-rc01"

    // To use the Animator APIs
    implementation "androidx.core:core-animation:1.0.0-alpha02"
    // To test the Animator APIs
    androidTestImplementation "androidx.core:core-animation-testing:1.0.0-alpha02"
}


dependencies {
    def fragment_version = "1.2.5"

    // Java language implementation
    implementation "androidx.fragment:fragment:$fragment_version"
    // Kotlin
    implementation "androidx.fragment:fragment-ktx:$fragment_version"
    // Testing Fragments in Isolation
    debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
}


DataStore

類(lèi)型化

// Typed DataStore (Typed API surface, such as Proto)
dependencies {
  implementation "androidx.datastore:datastore:1.0.0-alpha05"
}
// Alternatively - use the following artifact without an Android dependency.
dependencies {
  implementation "androidx.datastore:datastore-core:1.0.0-alpha05"
}

偏好設(shè)置化

// Preferences DataStore (SharedPreferences like APIs)
dependencies {
  implementation "androidx.datastore:datastore-preferences:1.0.0-alpha05"
}
// Alternatively - use the following artifact without an Android dependency.
dependencies {
  implementation "androidx.datastore:datastore-preferences-core:1.0.0-alpha05"
}

使用物理特性制作流暢動(dòng)畫(huà)

dependencies {
        // Java language implementation
        implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"

        // Kotlin
        implementation "androidx.dynamicanimation:dynamicanimation-ktx:1.0.0-alpha03"
    }

lifeCycle

dependencies {
    def lifecycle_version = "2.2.0"
    def arch_version = "2.1.0"

    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    // Lifecycles only (without ViewModel or LiveData)
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

    // Saved state module for ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"

    // Annotation processor
    kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
    // alternately - if using Java8, use the following instead of lifecycle-compiler
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    // optional - helpers for implementing LifecycleOwner in a Service
    implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"

    // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
    implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"

    // optional - ReactiveStreams support for LiveData
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"

    // optional - Test helpers for LiveData
    testImplementation "androidx.arch.core:core-testing:$arch_version"
}

加載器

dependencies {
        implementation "androidx.loader:loader:1.1.0"
    }

Media2

沒(méi)有官方文檔
與其他應(yīng)用共享媒體內(nèi)容和控件。

dependencies {
    def media2_version = "1.1.1"

    // Interacting with MediaSessions
    implementation "androidx.media2:media2-session:$media2_version"
    // optional - UI widgets for VideoView and MediaControlView
    implementation "androidx.media2:media2-widget:$media2_version"
    // optional - Implementation of a SessionPlayer
    implementation "androidx.media2:media2-player:$media2_version"
}

Mediarouter

利用通用界面實(shí)現(xiàn)在遠(yuǎn)程接收端設(shè)備上顯示和播放媒體內(nèi)容。

dependencies {
    implementation "androidx.mediarouter:mediarouter:1.2.0"
}

paging 3

dependencies {
  def paging_version = "3.0.0-alpha11"

  implementation "androidx.paging:paging-runtime:$paging_version"

  // alternatively - without Android dependencies for tests
  testImplementation "androidx.paging:paging-common:$paging_version"

  // optional - RxJava2 support
  implementation "androidx.paging:paging-rxjava2:$paging_version"

  // optional - RxJava3 support
  implementation "androidx.paging:paging-rxjava3:$paging_version"

  // optional - Guava ListenableFuture support
  implementation "androidx.paging:paging-guava:$paging_version"

  // Jetpack Compose Integration
  implementation "androidx.paging:paging-compose:1.0.0-alpha04"
}

room

dependencies {
  def room_version = "2.2.5"

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

  // optional - Kotlin Extensions and Coroutines support for Room
  implementation "androidx.room:room-ktx:$room_version"

  // optional - Test helpers
  testImplementation "androidx.room:room-testing:$room_version"
}

sqlist

 dependencies {
        def sqlite_version = "2.1.0"

        // Java language implementation
        implementation "androidx.sqlite:sqlite:$sqlite_version"

        // Kotlin
        implementation "androidx.sqlite:sqlite-ktx:$sqlite_version"

        // Implementation of the AndroidX SQLite interfaces via the Android framework APIs.
        implementation "androidx.sqlite:sqlite-framework:$sqlite_version"
    }
    

Vectordrawable

渲染矢量圖標(biāo)

dependencies {
    implementation "androidx.vectordrawable:vectordrawable:1.1.0"

    /* To be able to animate properties of a VectorDrawable, add the following.  Useful for
     * illustration purposes or state changes in response to user events
     */
    implementation "androidx.vectordrawable:vectordrawable-animated:1.1.0"

    /* To use a seekable alternative for `androidx.vectordrawable:vectordrawable-animated` add the
     * following
     */
     implementation "androidx.vectordrawable:vectordrawable-seekable:1.0.0-alpha02"
}

work

dependencies {
  def work_version = "2.4.0"

    // (Java only)
    implementation "androidx.work:work-runtime:$work_version"

    // Kotlin + coroutines
    implementation "androidx.work:work-runtime-ktx:$work_version"

    // optional - RxJava2 support
    implementation "androidx.work:work-rxjava2:$work_version"

    // optional - GCMNetworkManager support
    implementation "androidx.work:work-gcm:$work_version"

    // optional - Test helpers
    androidTestImplementation "androidx.work:work-testing:$work_version"
  }

hilt

dependencies {

    api "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
    api 'androidx.hilt:hilt-work:1.0.0-alpha03'
   // When using Kotlin.
    kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'

    api "com.google.dagger:hilt-android:2.28-alpha"
    kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"
}

注意:在某些依賴(lài)中會(huì)包含了java和kotlin兩種(標(biāo)注了 java only的),請(qǐng)根據(jù)語(yǔ)言環(huán)境選擇使用。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容