Adding a Library

Most of an Android app comes from code that you did not write. It comes from code written by others, in the form of libraries. Even though we have not gotten very far with the ToDo app, we are already using some libraries, and in this chapter, we will update that roster.

This is a continuation of the work we did in the previous tutorial. The book’s GitLab repository contains the results of the previous tutorial as well as the results of completing the work in this tutorial.

You can learn more about Gradle in the "Reviewing Your Gradle Scripts" chapter of Elements of Android Jetpack!

Step #1: Examining What We Have

Open app/build.gradle in Android Studio. You will find that it contains a dependencies closure that looks like this:

dependencies {
  implementation 'androidx.core:core-ktx:1.6.0'
  implementation 'androidx.appcompat:appcompat:1.3.1'
  implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
  testImplementation 'junit:junit:4.13.2'
  androidTestImplementation 'androidx.test.ext:junit:1.1.3'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

A new Android Studio project will contain this sort of initial set of dependencies, though the details will vary a bit depending on Android Studio version and the particular choices you make when creating the project. The implementation, testImplementation, and androidTestImplementation lines indicate libraries that we want to use, where implementation is for our app and the others are for our tests.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.