The Generated Source Sets

Inside the src/ directory are “source sets”. These identify different directories of source code (and related files) that will be used in different circumstances:

Android Studio Project View, Showing src/ Entries
Android Studio Project View, Showing src/ Entries

There are three source sets that will be created by default for an Android project: main/, androidTest/ and test/.

main/

The source set that you will spend most of your time in is main/. This represents the “main” source code for your app. For most apps, this source set contains all of your code (and related files) that make up the app itself:

Android Studio Project View, Showing main Source Set Entries
Android Studio Project View, Showing main Source Set Entries

Your Java and Kotlin code will go in a java/ directory inside of the source set. Here, we see one Kotlin file, named MainActivity.kt (where the .kt part is left off in the tree).

You will also find:

androidTest/

The androidTest/ source set can have its own Java/Kotlin source code, resources, and manifest file. Typically, it only has Java and Kotlin source code:

Android Studio Project View, Showing androidTest Source Set Entries
Android Studio Project View, Showing androidTest Source Set Entries

This source set’s files will not go into your app. Instead, they are for testing your app, to make sure that your app does what it is supposed to do.

test/

There is a very similar source set, named test/, in a typical Android project:

Android Studio Project View, Showing test Source Set Entries
Android Studio Project View, Showing test Source Set Entries

As with androidTest/, test/ can contain its own Java and Kotlin code. And, as with the androidTest/ source set, the test/ code is not part of your app, but instead is for testing your app.

The difference between androidTest/ and test/ is in where your tests run:

We will explore that distinction in greater detail, along with the test code in our starter project, later in the book.


Prev Table of Contents Next

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