Project Structure & Gradle Sync
Android Studio: The IDE Itself
Chapter 2 · Project Structure & Gradle Sync
Chapter 1 placed project structure and Gradle sync squarely on the Android-specific side of the IDE — nothing here exists in a plain IntelliJ IDEA install with no Android support. This chapter covers both directly: how an Android Studio project is actually organized, and what that "Gradle Sync" progress bar is really doing.
build.gradle.kts and settings.gradle.kts, plus a version catalog (gradle/libs.versions.toml). Plugin and library versions live in the catalog, and the project-level file holds only lines such as alias(libs.plugins.android.application) apply false. The samples below use the older Groovy form; the ideas (project-level versus module-level, what Sync does) are unchanged. Checked on a Rabbit 2 project in November 2026: Android Gradle Plugin 9.5.1, Gradle 9.6.
Android Studio's Project Structure
An Android Studio project is not one flat folder of files — it's organized into modules, most commonly at least one app module (the application itself) and optionally additional library modules. Inside the app module, source code lives under app/src/main/java and resources (layouts, strings, images) under app/src/main/res. This module-based layout, and the project/module distinction it creates, is fundamentally different from a simpler text editor's own flat "just a folder of files" view.
What Gradle Actually Is
Gradle itself is a general-purpose build automation tool, used well beyond Android — it isn't something Google invented. Android's own build process is layered on top of plain Gradle via the Android Gradle Plugin (AGP), which adds Android-specific build steps (packaging an APK, handling resources, managing the Android SDK) to Gradle's own general build-automation engine.
build.gradle Files: Two Different Scopes
A common early point of confusion: there isn't just one build.gradle file. The project-level file (alongside settings.gradle) configures overall build settings and lists which modules belong to the project. The module-level file — app/build.gradle — is where SDK versions, the application ID, and individual library dependencies actually live. Adding a new library dependency almost always means editing the module-level file, not the project-level one.
What "Gradle Sync" Is Actually Doing
Clicking Sync Now (or first opening a project) isn't just Android Studio reloading files from disk. It actually runs Gradle itself: resolving every declared dependency, downloading any new libraries that aren't already cached locally, and regenerating the IDE's own internal understanding of the project's module and dependency graph — the information code completion, error-checking, and navigation all depend on being accurate. This is a real process that touches the network and disk, which is why it can genuinely take real time, especially after adding a new dependency for the first time — not an instant IDE refresh.
When You Need to Sync Manually
Editing build.gradle — adding a dependency, changing an SDK version — has no effect on the actual project until a sync happens. Android Studio usually detects the change and shows a "Sync Now" banner automatically, but that banner can be missed or accidentally dismissed; knowing the toolbar's own Sync button exists (rather than assuming something is broken) avoids real confusion when code that should now be available still shows as unresolved.
| File | Scope | Controls |
|---|---|---|
Project-level build.gradle | Whole project | Plugin versions, overall build settings |
settings.gradle | Whole project | Which modules belong to the project |
Module-level app/build.gradle | One module (app) | SDK versions, application ID, dependencies |
build.gradle files genuinely define the actual build — they belong in version control (Git & GitHub Foundations' own material) alongside the rest of the project's source, not excluded via .gitignore the way IDE-generated cache/workspace files typically are.
build.gradle without noticing the sync banner. The fix in that situation is almost always Sync Now, not restarting the IDE or reinstalling anything.
Hands-On Exercises
A developer wants to add a new library dependency to their app. Which build.gradle file should they edit — the project-level one or the module-level one — and why?
📄 View solutionAfter pulling new commits from a teammate that added a dependency to app/build.gradle, a developer sees the newly-added library's classes showing as "cannot resolve symbol" in their editor. Using this chapter's own material, explain the likely cause and the fix — without assuming the IDE itself is broken.
📄 View solutionExplain, in your own words, why Gradle Sync can genuinely take real time to complete (sometimes noticeably so), rather than being an instant operation the way simply opening a file is.
📄 View solutionChapter 2 Quick Reference
- An Android Studio project is organized into modules (e.g.
app), not one flat folder - Gradle is a general build tool; the Android Gradle Plugin (AGP) adds Android-specific build steps on top of it
- Project-level
build.gradle/settings.gradlevs. module-levelapp/build.gradle— dependencies almost always go in the module-level file - Gradle Sync genuinely resolves dependencies and rebuilds the IDE's own project understanding — a real process, not an instant refresh
- "Cannot resolve symbol" after a
build.gradlechange is almost always a missed sync, not a broken IDE