The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Tutorial #6 - Adding a Library

We will want to use some third-party libraries in our project, to ease development of the app:

Right now, we will just focus on arranging for our project to be able to use the libraries. Later in the book, we will actually put the libraries to use.

This is a continuation of the work we did in the previous tutorial.

You can find the results of the previous tutorial and the results of this tutorial in the book’s GitHub repository.

Step #1: Getting Rid of Existing Cruft

If you look at the app/build.gradle file, you will see that we already have some dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
}

These dependencies are the sort of thing that gets added automatically to your project by the new-project wizard. While you imported your starter project, rather than creating it from scratch, the starter project has these dependencies because it was created from the new-project wizard.

However, we are not going to use any of those dependencies:

However, not only does the new-project wizard generate dependencies like these for us, but it also code-generates some do-nothing test code that depends upon these dependencies. So, we will leave those two test dependencies alone, as it is simpler to ignore them than it is to clean that part up.

But go ahead and delete the implementation fileTree statement, leaving you with

dependencies {
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
}

You may get a yellow banner at the top of the editor, indicating that a “project sync” is requested. Ignore that for the moment, as we will be making more changes to this file.

Step #2: Requesting New Dependencies

The preview of this section is en route to Mars.

In Our Next Episode…

The preview of this section is presently indisposed.