Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
🟢 शुरुआत  ·  Lesson 04

Project Structure: Manifest, Gradle, res

Folder tree

यह course के आख़िर में बनने वाली Student Diary app का असली structure है:

📁 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
Android project (Project view)

AndroidManifest.xml

Manifest app का ID card है: icon और name, Application class, हर Activity, और ज़रूरी permissions। जिस activity में MAIN/LAUNCHER intent-filter है वही 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 build tool है। यह libraries download करता है, Kotlin compile करता है, resources pack करता है और APK sign करता है।

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मतलब
namespaceGenerated R class का package
applicationIdPlay Store पर unique app ID
minSdk / targetSdk / compileSdkसबसे पुराना supported / tested / compile वाला Android version
versionCode / versionNameInternal number (हर release पर बढ़ाएँ) / users को दिखने वाला text
viewBinding = trueLayouts के लिए binding classes बनाता है

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)
libs.versions.tomlmaterial = 1.12.0build.gradle.ktsimplementation(libs.material)Gradle synclibrary download
सारे versions update करने के लिए एक file

res folder

Folderक्या हैकैसे use
layout/Screen XMLR.layout.x
values/strings.xmlसारे texts@string/x, R.string.x
values/colors.xml, themes.xmlColours और theme@color/x, @style/x
drawable/Vector icons, shapes, images@drawable/x
mipmap-*/Launcher icon@mipmap/ic_launcher
menu/, navigation/Menus, nav graphR.menu.x, @navigation/x
values-night/, values-hi/Dark mode / Hindi overridesअपने आप चुनी जाती हैं

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)

  • Files type के हिसाब से group
  • Build folders छिपे
  • Daily coding के लिए best

Project view

  • Disk के असली folders
  • gradle/wrapper, build/ दिखते हैं
  • Structure समझने के लिए best
Project panel के ऊपर dropdown से बदलें

आम गलतियाँ

  • Resource names में capital letters या spaces (Main Logo.png) → सिर्फ़ a-z 0-9 _ allowed।
  • build/ के अंदर files edit करना → ये दोबारा बनती हैं; कभी edit न करें।
  • नई Activity manifest में declare करना भूलना → ActivityNotFoundException।
  • Publish के बाद applicationId बदलना → Play इसे नई app मानता है।

सारांश

  • Manifest = identity + components + permissions।
  • Gradle (Kotlin DSL) app build करता है; versions libs.versions.toml में।
  • res/ में layouts, strings, colours, icons; generated R class से access।
✅ Practice

अपनी HelloApp में Project view पर जाइए, libs.versions.toml ढूँढिए, और res/values/strings.xml में app name बदलिए। Run करके icon के नीचे नया नाम देखिए।

अक्सर पूछे जाने वाले प्रश्न (FAQ)

दोनों build.gradle.kts files में क्या फ़र्क है?
Root वाली पूरे project के plugins declare करती है। app/build.gradle.kts app module configure करती है: SDK versions, applicationId, build features और dependencies।
applicationId क्या है?
Phone और Google Play पर आपकी app की unique ID, जैसे com.codingeasily.studentdiary। Publish करने के बाद इसे कभी न बदलें।
"Unresolved reference: R" क्यों आता है?
आमतौर पर किसी XML file में error है इसलिए R नहीं बन पाया, या import गलत है। Build window में दिखा XML error ठीक करके फिर sync करें।
← Android Tutorial (Kotlin)
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

अगला topicAndroid के लिए Kotlin Basics आपकी प्रगति: 4 / 43 (9%) · Lesson 5 / 43 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें