Overview
TechSales uses Gradle’s version catalog feature for centralized dependency management. All dependencies are declared ingradle/libs.versions.toml and referenced type-safely in build files.
App Dependencies
The application module declares its dependencies inapp/build.gradle.kts:
app/build.gradle.kts
Core Dependencies
AndroidX AppCompat
Provides backward-compatible versions of Android framework APIs.Version: 1.6.1
Group: androidx.appcompat
Artifact: appcompat
Group: androidx.appcompat
Artifact: appcompat
- Material Design components
- ActionBar and Toolbar support
- AppCompatActivity and theme support
- Vector drawables on older Android versions
AppCompat is essential for maintaining consistency across Android versions. It backports newer UI components to older devices.
Material Design Components
Google’s Material Design component library for Android.Version: 1.10.0
Group: com.google.android.material
Artifact: material
Group: com.google.android.material
Artifact: material
- Material Design 3 components
- Bottom sheets, navigation drawers, cards
- Floating action buttons (FAB)
- Text fields and input layouts
- Snackbars and dialogs
AndroidX Activity
Modern activity handling with result contracts and ViewModels.Version: 1.8.0
Group: androidx.activity
Artifact: activity
Group: androidx.activity
Artifact: activity
- Activity Result API
- ComponentActivity base class
- OnBackPressedDispatcher
- Integration with ViewModels and Lifecycle
ConstraintLayout
Flexible layout manager for creating responsive UIs.Version: 2.1.4
Group: androidx.constraintlayout
Artifact: constraintlayout
Group: androidx.constraintlayout
Artifact: constraintlayout
- Flat view hierarchy for better performance
- Responsive layouts without nested ViewGroups
- Constraint-based positioning
- Guidelines, barriers, and chains
ConstraintLayout is the recommended layout manager for modern Android apps. It reduces layout nesting and improves performance.
Test Dependencies
JUnit 4
Standard unit testing framework for Java/Kotlin.Version: 4.13.2
Group: junit
Artifact: junit
Configuration: testImplementation
Group: junit
Artifact: junit
Configuration: testImplementation
- Unit tests for business logic
- ViewModel testing
- Repository and data source tests
- Utility function tests
AndroidX JUnit Extension
AndroidX test runner with JUnit 4 integration.Version: 1.1.5
Group: androidx.test.ext
Artifact: junit
Configuration: androidTestImplementation
Group: androidx.test.ext
Artifact: junit
Configuration: androidTestImplementation
- Instrumented tests that require Android context
- Activity and Fragment testing
- Integration tests
Espresso
UI testing framework for Android.Version: 3.5.1
Group: androidx.test.espresso
Artifact: espresso-core
Configuration: androidTestImplementation
Group: androidx.test.espresso
Artifact: espresso-core
Configuration: androidTestImplementation
- UI interaction testing
- View matching and assertions
- Automated user flow testing
Espresso tests run on real devices or emulators and can interact with your app’s UI like a real user would.
Version Catalog Structure
The version catalog is defined ingradle/libs.versions.toml:
gradle/libs.versions.toml
Structure Breakdown
[versions] Section:- Declares version numbers as variables
- Referenced using
version.refin library declarations - Single source of truth for versions
- Declares dependencies with Maven coordinates
- Format:
{ group = "...", name = "...", version.ref = "..." } - Accessed in build files as
libs.libraryName
- Declares Gradle plugins
- Accessed as
libs.plugins.pluginName
Dependency Configurations
Implementation
- Used for dependencies required at runtime
- Not exposed to consumers (in library modules)
- Faster compilation than
api
TestImplementation
- Used for unit test dependencies
- Only available in
testsource set - Not included in APK
AndroidTestImplementation
- Used for instrumented test dependencies
- Only available in
androidTestsource set - Not included in production APK
Choose the most restrictive configuration possible. Using
testImplementation instead of implementation for test-only dependencies reduces APK size.Adding New Dependencies
Step 1: Add Version to Catalog
Editgradle/libs.versions.toml:
Step 2: Add to Build File
Editapp/build.gradle.kts:
Step 3: Sync Project
Click “Sync Now” in Android Studio or run:Android Studio provides auto-completion for version catalog entries. Type
libs. to see available dependencies.Updating Dependencies
Manual Updates
- Edit version in
gradle/libs.versions.toml - Sync the project
- Test thoroughly
Checking for Updates
Use the Gradle Versions Plugin:build.gradle.kts
Dependency Management Best Practices
1. Use Version Catalogs
2. Group Related Versions
3. Use Specific Configurations
4. Avoid Dynamic Versions
5. Document Custom Dependencies
Add comments inlibs.versions.toml for non-standard dependencies:
Viewing Dependency Tree
To see all dependencies and their transitive dependencies:Resolving Dependency Conflicts
When multiple dependencies require different versions of the same library:Common Dependencies to Add
Here are commonly added dependencies for Android apps:Related Documentation
- Gradle Configuration - Gradle setup and build configuration
- Build Types - Debug and release configurations
- Testing - Writing and running tests