Difference between project and module build.gradle files?

This tests your understanding of Gradle's project structure and build configuration scope. The project-level file configures global settings like repositories, while the module-level file configures specifics like dependencies and app ID.
What's really being asked
This question assesses your grasp of the fundamental structure of an Android Gradle project. It checks if you understand the hierarchy and scope of build configurations: what settings apply globally to all modules versus what settings are specific to a single module (like an app or a library). For a senior candidate, it's about demonstrating clear, precise knowledge of the build system's core concepts.
The full answer
A good answer outlines the distinct responsibilities of each file. First, the project-level (or root) build.gradle file is for settings that apply to the entire project. This includes defining the repositories (like google() and mavenCentral()) where Gradle should look for plugins and dependencies, and often specifying the versions of common plugins (like the Android Gradle Plugin and Kotlin Gradle Plugin) that all modules will use. Second, the module-level build.gradle file (e.g., app/build.gradle) is for settings specific to that one module. This is where you apply the plugins (like com.android.application or com.android.library), set the applicationId, define minSdk and targetSdk, list the module's specific dependencies in the dependencies block, and configure build types (release, debug) and product flavors.
The mistakes people make
A major red flag is confusing the roles. For example, stating that you declare app dependencies (like Retrofit or Glide) in the root build.gradle file. The root file only declares the repositories where those dependencies can be found. Another mistake is mixing up plugin application (apply plugin: 'com.android.application') which happens at the module level, with plugin version definition, which is often centralized in the root project's plugins block or a version catalog. Saying the root file contains the applicationId or minSdk is also incorrect.
What usually comes next
"How have build.gradle files evolved with modern Gradle, for example, with the plugins block or version catalogs?" "Where would you define a variable to be used across multiple module-level build.gradle files?" "What is the purpose of the settings.gradle file?"
A concrete example
In the project-level build.gradle.kts, you might see a plugins block defining id("com.android.application") version "8.2.0" apply false. The apply false is key; it makes the plugin available to sub-projects but doesn't apply it. Then, in the module-level app/build.gradle.kts, you would simply have plugins { id("com.android.application") } to actually apply it to the app module. Similarly, the project-level file has repositories { google(); mavenCentral() }, while the module-level file has dependencies { implementation("androidx.core:core-ktx:1.12.0") }.
Interview question
To add a new library like Retrofit for use only within your app module, where should you declare the `implementation` dependency?
- a.In the `dependencies` block of the module-level build.gradle file.Correct
- b.In the `repositories` block of the project-level build.gradle file.
- c.In the `dependencies` block of the project-level build.gradle file.
- d.In the `plugins` block of the project-level build.gradle file.
Why? this is the answer
The module-level build.gradle file is for settings specific to that module, including its library dependencies. The project-level file is for global settings, like defining repositories where dependencies are found, not for declaring the dependencies themselves.
Just read this? Test yourself on what you have been reading.
Read the original → developer.android.com
- #android
- #gradle
- #build system
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.
See open roles