android tutorial - Why are there two build.gradle files in an android Studio project? | Developer android - android app development - android studio - android app developement
- <PROJECT_ROOT>\app\build.gradle is specific for app module.
- <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
- If you use another module in your project, as a local library you would have another build.gradle file: <PROJECT_ROOT>\module\build.gradle
The Top-level Build File
The top-level build.gradle file, located in the root project directory, defines build configurations that apply to all modules in your project. By default, the top-level build file uses the buildscript {} block to define the Gradle repositories and dependencies that are common to all modules in the project. The following code sample describes the default settings and DSL elements you can find in the top-level build.gradle after creating a new project.
The Module-level Build File
The module-level build.gradle file, located in each <project>/<module>/ directory, allows you to configure build settings for the specific module it is located in. Configuring these build settings allows you to provide custom packaging options, such as additional build types and product flavors, and override settings in the main/ app manifest or top-level build.gradle file.