🟢 Getting Started · Lesson 04
Project Structure: Manifest, Gradle, res
The folder tree
This is the real structure of the Student Diary app you will build at the end of the course:
📁 StudentDiary/ ├─ settings.gradle.kts # project name + which modules exist ├─ build.gradle.kts # root: plugins for all modules ├─ gradle.properties # Gradle/AndroidX flags ├─ 📁 gradle/ │ ├─ libs.versions.toml # all library versions in one place │ └─ 📁 wrapper/ # fixed Gradle version for everyone └─ 📁 app/ ├─ build.gradle.kts # app module: SDKs, dependencies ├─ proguard-rules.pro # code shrinking rules (release) └─ 📁 src/main/ ├─ AndroidManifest.xml # app identity, screens, permissions ├─ 📁 java/com/codingeasily/studentdiary/ # Kotlin code └─ 📁 res/ ├─ 📁 layout/ # screen designs (XML) ├─ 📁 values/ # strings, colors, themes ├─ 📁 values-night/ # dark mode overrides ├─ 📁 drawable/ # icons, shapes ├─ mipmap-*/ # launcher icon ├─ 📁 menu/ # toolbar/drawer menus └─ 📁 navigation/ # nav_graph.xml
AndroidManifest.xml
The manifest is the app's ID card: its icon and name, the Application class, every Activity, and the permissions it needs. The activity with the MAIN/LAUNCHER intent-filter is the one opened from the home screen.
XML – app/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Needed for the Help screen (WebView) and the "Tip of the day" (Retrofit) -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Android 13+ asks the user before showing notifications -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:name=".StudentDiaryApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.StudentDiary">
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>Gradle files
Gradle is the build tool. It downloads libraries, compiles Kotlin, packs resources and signs the APK.
Kotlin DSL – settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "StudentDiary"
include(":app")Kotlin DSL – app/build.gradle.kts
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp) // generates Room code
}
android {
namespace = "com.codingeasily.studentdiary"
compileSdk = 35
defaultConfig {
applicationId = "com.codingeasily.studentdiary"
minSdk = 26
targetSdk = 35
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
viewBinding = true // generates ActivityMainBinding, FragmentNotesBinding, ...
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.viewpager2)
implementation(libs.androidx.activity.ktx)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.retrofit)
implementation(libs.retrofit.converter.gson)
implementation(libs.glide)
testImplementation(libs.junit)
}| Setting | Meaning |
|---|---|
| namespace | Package used for the generated R class |
| applicationId | Unique app ID on Play Store |
| minSdk / targetSdk / compileSdk | Oldest supported / tested / compiled-against Android version |
| versionCode / versionName | Internal number (increase every release) / text shown to users |
| viewBinding = true | Generates binding classes for layouts |
Version catalog (libs.versions.toml)
TOML
# gradle/libs.versions.toml (part)
[versions]
agp = "8.7.3"
kotlin = "2.0.21"
material = "1.12.0"
room = "2.6.1"
[libraries]
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
# used in app/build.gradle.kts as: implementation(libs.material)The res folder
| Folder | Contains | Used as |
|---|---|---|
| layout/ | Screen XML | R.layout.x |
| values/strings.xml | All texts | @string/x, R.string.x |
| values/colors.xml, themes.xml | Colours and theme | @color/x, @style/x |
| drawable/ | Vector icons, shapes, images | @drawable/x |
| mipmap-*/ | Launcher icon | @mipmap/ic_launcher |
| menu/, navigation/ | Menus, nav graph | R.menu.x, @navigation/x |
| values-night/, values-hi/ | Dark mode / Hindi overrides | picked automatically |
The R class
Kotlin
// res/layout/activity_main.xml → R.layout.activity_main // android:id="@+id/btnSave" → R.id.btnSave // <string name="app_name"> → R.string.app_name // res/drawable/ic_add.xml → R.drawable.ic_add setContentView(R.layout.activity_main) val title = getString(R.string.app_name) binding.fab.setImageResource(R.drawable.ic_add)
Android view vs Project view
Android view (default)
- Groups files by type
- Hides build folders
- Best for daily coding
Project view
- Real folders on disk
- Shows gradle/wrapper, build/
- Best to understand structure
Common mistakes
- Capital letters or spaces in resource names (
Main Logo.png) → onlya-z 0-9 _allowed. - Editing files inside
build/→ they are regenerated; never edit them. - Forgetting to declare a new Activity in the manifest →
ActivityNotFoundException. - Changing
applicationIdafter publishing → Play treats it as a new app.
Summary
- Manifest = identity + components + permissions.
- Gradle (Kotlin DSL) builds the app; versions live in libs.versions.toml.
- res/ holds layouts, strings, colours, icons; accessed through the generated R class.
✅ Practice
In your HelloApp, switch to Project view, find libs.versions.toml, and change the app name in res/values/strings.xml. Run and see the new name under the icon.
Frequently Asked Questions
What is the difference between the two build.gradle.kts files?
The root one declares plugins for the whole project. app/build.gradle.kts configures the app module: SDK versions, applicationId, build features and dependencies.
What is applicationId?
The unique ID of your app on the phone and on Google Play, for example com.codingeasily.studentdiary. Never change it after publishing.
Why do I get "Unresolved reference: R"?
Usually an XML file has an error so R could not be generated, or the import is wrong. Fix the XML error shown in the Build window and sync again.
