It's a bit confusing because Android Studio by default shows both
build.gradle files right next to each other (when using the Android view).
If you switch to the Project view you can see the actual structure and where the different
build.gradle files are located.
build.gradle (Project: MyApplication) file is in the root folder of the project and its configuration settings apply to every module in the project. A module is an isolated piece of the bigger project. In a multi-module project, these modules have their own jobs but work together to form the whole project. Most Android projects only have one module, the app module.
build.gradle (Module: app) file here is in the
app folder. Its build settings apply only to the app module. If there were another module, then the it would have its own
build.gradle file, too. As an example, I made a library project with three modules: a library module, a demo app module, and another app module that I plan to use for testing. Each of them have their own
build.gradle files that I can tweak.
In a basic project, almost everything you need to edit will be in the app module's
build.gradle file. You can remember it like this:
You're making an app, so go to the
build.gradle (Module: app) file.
- Configure Your Build (Android documentation--very readable and useful)
- Introduction to multi-project builds (Gradle documentation)