Learning Mobile Development

Bundle Android Dependencies Using Gradle’s VersionCatalogs

A Gradle 7.0 new feature to make dependencies grouping nicer

Photo by Denny Müller on Unsplash

When you create a default Jetpack Compose App using Android Studio, you’ll probably have the below list of dependencies.

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

How nice if it is all bundled together and we can just do this

implementation (baseLibs.bundles.suite)
testImplementation (baseLibs.junit)
androidTestImplementation (baseLibs.bundles.android.test)
debugImplementation (baseLibs.compose.ui.tooling)

--

--