Search code examples
android-studiokotlindependenciesandroid-jetpack-composegradle-kotlin-dsl

Android Canary dependencies for jetpack compose


I just started learning jetpack compose and I have a few questions

  1. Should I use "Use kotlin script(.kts) for Gradle build files" and if yes what are the benefits?

  2. Also how do I keep up with dependencies

    Dependencies from a developers show older versions then the one in android studio canary. Some of them are either not there at all or version is different

do I need to include these

implementation 'androidx.compose.foundation:foundation:1.0.0-beta01'
implementation 'androidx.compose.material:material-icons-core:1.0.0-beta01'
implementation 'androidx.compose.material:material-icons-extended:1.0.0-beta01'
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta01'
implementation 'androidx.compose.runtime:runtime-rxjava2:1.0.0-beta01'

implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha02'

do I need to include that

implementation 'androidx.compose.material:material:1.0.0-beta01'

or it was replaced by

implementation 'com.google.android.material:material:1.3.0'

where can I check new version and if it's compatible

implementation 'androidx.activity:activity-compose:1.3.0-alpha03'

implementation 'androidx.activity:activity-compose:1.3.0-alpha06

Included as default in AS canary

dependencies {

    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha06'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
}

Solution

    1. you can use both gradle and gradle.kts files, whichever suits you.

    you can read about the benefits of kts in the official documentation

    if you're totally comfortable with gradle files, there's no reason to switch, but if you're starting from the ground, I'd advise you to use kts

    1. the current set of dependencies you always can find in compose-samples

    This repo contains samples made by compose maintainers and gets updated on each release. You can subscribe to release notifications to always be up-to-date.

    my current set of deps:

    let composeVersion = "1.0.0-beta05"
    
    "androidx.appcompat:appcompat:1.3.0-beta01"
    "androidx.core:core-ktx:1.3.2"
    "com.google.android.material:material:1.3.0"
    "androidx.activity:activity-ktx:1.2.1"
    "androidx.activity:activity-compose:1.3.0-alpha07"   
    "androidx.compose.ui:ui:$composeVersion"
    "androidx.compose.foundation:foundation:$composeVersion"
    "androidx.compose.material:material:$composeVersion"
    "androidx.compose.material:material-icons-core:$composeVersion"