Why are there two build.gradle files in an Android Studio project

suggest change

<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

In the top level file you can specify common properties as the buildscript block or some common properties.

buildscript {
    repositories {

    dependencies {
       classpath 'com.android.tools.build:gradle:2.2.0'
       classpath 'com.google.gms:google-services:3.0.0'

ext {
    compileSdkVersion = 23
    buildToolsVersion = "23.0.1"

In the app\build.gradle you define only the properties for the module:

apply plugin: 'com.android.application'
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

dependencies {

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents