Dependencies
Learn about the dependencies involved in developing an Android application.
In this chapter, we’ll look at Android dependencies and see how they’re involved in our application and the project structure, which is located in the Appendix.
Press + to interact
dependencies {implementation 'androidx.core:core-ktx:1.7.0'//noinspection GradleDependencyimplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"implementation 'androidx.appcompat:appcompat:1.4.0'implementation 'com.google.android.material:material:1.4.0'implementation 'androidx.constraintlayout:constraintlayout:2.1.2'implementation 'androidx.legacy:legacy-support-v4:1.0.0'testImplementation 'junit:junit:4.13.2'androidTestImplementation 'androidx.test.ext:junit:1.1.3'androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'// Architectural Componentsimplementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"implementation 'androidx.appcompat:appcompat:1.4.0'// Roomimplementation "androidx.room:room-runtime:2.4.2"kapt "androidx.room:room-compiler:2.4.2"// Kotlin Extensions and Coroutines support for Roomimplementation "androidx.room:room-ktx:2.3.0"// Coroutinesimplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'// Coroutine Lifecycle Scopesimplementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"// Retrofitimplementation 'com.squareup.retrofit2:retrofit:2.9.0'implementation 'com.squareup.retrofit2:converter-gson:2.9.0'implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"// Navigation Componentsimplementation "androidx.navigation:navigation-fragment-ktx:2.3.5"implementation "androidx.navigation:navigation-ui-ktx:2.3.5"// Glideimplementation 'com.github.bumptech.glide:glide:4.12.0'kapt 'com.github.bumptech.glide:compiler:4.11.0'implementation "androidx.core:core-ktx:1.7.0"}
Let’s look at each of the dependencies above and how they’re related to our application.
The RoomDatabase
dependency
The Room
library is built on top of the SQLite
database acting as an abstraction layer and serves as a data persistence library used to cache
data locally when online. We can also access this data while offline. To use it, we first add the following dependency to our build.gradle
file:
Press + to interact
dependencies {implementation "androidx.room:room-runtime:2.4.2"kapt "androidx.room:room-compiler:2.4.2"}
Why to use Room
- It’s easy to use since all the boilerplate code we had to write while using SQLite database is now abstracted and provided automatically in the background.