Bird
Raised Fist0
Android Kotlinmobile~20 mins

Project structure (app, gradle, manifests) in Android Kotlin - Mini App: Build & Ship

Choose your learning style10 modes available
Build: Project Structure Overview
This screen shows the basic Android project structure focusing on app module, Gradle files, and manifest files.
Target UI
----------------------------------
| Android Project Structure       |
|--------------------------------|
| app/                           |
|   ├─ src/                      |
|   │   ├─ main/                 |
|   │   │   ├─ java/             |
|   │   │   ├─ res/              |
|   │   │   └─ AndroidManifest.xml|
|   ├─ build.gradle              |
| build.gradle (project level)  |
| settings.gradle               |
----------------------------------
Display a simple list showing main folders and files: app module folder, src/main folder, java folder, res folder, AndroidManifest.xml file
Show build.gradle files for app module and project level
Show settings.gradle file
Use a vertical list with indentation to represent folder hierarchy
Use simple TextViews with proper indentation
Add a header title 'Android Project Structure'
Starter Code
Android Kotlin
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

class MainActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      MaterialTheme {
        Surface(modifier = Modifier.padding(16.dp)) {
          Column {
            // TODO: Add project structure list here
          }
        }
      }
    }
  }
}
Task 1
Task 2
Task 3
Solution
Android Kotlin
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

class MainActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      MaterialTheme {
        Surface(modifier = Modifier.padding(16.dp)) {
          Column {
            Text(
              text = "Android Project Structure",
              fontSize = 24.sp,
              fontWeight = FontWeight.Bold,
              modifier = Modifier.padding(bottom = 16.dp)
            )
            Text(text = "app/", modifier = Modifier.padding(start = 0.dp, bottom = 4.dp))
            Text(text = "├─ src/", modifier = Modifier.padding(start = 16.dp, bottom = 4.dp))
            Text(text = "│  ├─ main/", modifier = Modifier.padding(start = 32.dp, bottom = 4.dp))
            Text(text = "│  │  ├─ java/", modifier = Modifier.padding(start = 48.dp, bottom = 4.dp))
            Text(text = "│  │  ├─ res/", modifier = Modifier.padding(start = 48.dp, bottom = 4.dp))
            Text(text = "│  │  └─ AndroidManifest.xml", modifier = Modifier.padding(start = 48.dp, bottom = 8.dp))
            Text(text = "├─ build.gradle", modifier = Modifier.padding(start = 16.dp, bottom = 8.dp))
            Text(text = "build.gradle (project level)", modifier = Modifier.padding(start = 0.dp, bottom = 8.dp))
            Text(text = "settings.gradle", modifier = Modifier.padding(start = 0.dp))
          }
        }
      }
    }
  }
}

This solution uses Jetpack Compose to create a simple vertical list showing the Android project structure.

The Column arranges Text composables vertically. Indentation is done by adding left padding to each line to represent folder hierarchy visually.

The header uses a larger font size and bold weight to stand out.

This approach clearly shows the app module folder, source folders, manifest file, and Gradle files as requested.

Final Result
Completed Screen
----------------------------------
| Android Project Structure       |
|--------------------------------|
| app/                           |
|   ├─ src/                      |
|   │   ├─ main/                 |
|   │   │   ├─ java/             |
|   │   │   ├─ res/              |
|   │   │   └─ AndroidManifest.xml|
|   ├─ build.gradle              |
| build.gradle (project level)  |
| settings.gradle               |
----------------------------------
Screen is static showing the project structure list
User can scroll if screen is small (default Compose behavior)
No interactive elements on this screen
Stretch Goal
Add a button that shows a short explanation dialog about each file when tapped
💡 Hint
Use a Button composable and AlertDialog in Jetpack Compose to show file descriptions

Practice

(1/5)
1. What is the main purpose of the app folder in an Android project?
easy
A. It stores the build configuration files.
B. It contains the app's source code and resources.
C. It holds the Android system files.
D. It contains the device emulator settings.

Solution

  1. Step 1: Understand the app folder role

    The app folder is where you put your app's code and resources like images and layouts.
  2. Step 2: Differentiate from other folders

    Build files like build.gradle are outside or inside app but serve different purposes; system files are not in app.
  3. Final Answer:

    It contains the app's source code and resources. -> Option B
  4. Quick Check:

    App folder = source code and resources [OK]
Hint: App folder = your app's code and resources [OK]
Common Mistakes:
  • Confusing build files with app folder contents
  • Thinking system files are inside app folder
  • Mixing emulator settings with project structure
2. Which file in an Android project declares the app's components and permissions?
easy
A. build.gradle
B. proguard-rules.pro
C. settings.gradle
D. AndroidManifest.xml

Solution

  1. Step 1: Identify the manifest file role

    The AndroidManifest.xml file describes app components like activities and permissions.
  2. Step 2: Compare with other files

    build.gradle handles build settings, settings.gradle manages modules, and proguard-rules.pro is for code shrinking rules.
  3. Final Answer:

    AndroidManifest.xml -> Option D
  4. Quick Check:

    Manifest = app components and permissions [OK]
Hint: Manifest file = app components and permissions [OK]
Common Mistakes:
  • Confusing build.gradle with manifest
  • Thinking settings.gradle declares permissions
  • Mixing ProGuard rules with app declarations
3. Given this snippet from build.gradle inside the app folder, what will happen if you add a new dependency incorrectly?
dependencies {
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'com.google.android.material:material:1.7.0'
}
medium
A. The app will build successfully with all dependencies.
B. The app will run but crash at runtime due to missing classes.
C. The build will fail due to a syntax error in dependencies.
D. The build will ignore the incorrect dependency and continue.

Solution

  1. Step 1: Understand dependency syntax

    Dependencies must be declared with correct syntax like implementation 'group:name:version'. Any syntax error causes build failure.
  2. Step 2: Consequence of incorrect dependency

    If a dependency line is malformed, Gradle will fail to build and show an error, not ignore it or allow runtime crashes.
  3. Final Answer:

    The build will fail due to a syntax error in dependencies. -> Option C
  4. Quick Check:

    Incorrect dependency syntax = build failure [OK]
Hint: Syntax errors in build.gradle cause build failure [OK]
Common Mistakes:
  • Assuming build ignores syntax errors
  • Thinking runtime crashes happen from build errors
  • Confusing dependency syntax with code syntax
4. You added a new permission in AndroidManifest.xml but the app crashes on launch. What is a likely cause?
medium
A. The permission tag is outside the manifest root element.
B. The build.gradle file is missing the permission.
C. The app folder is empty.
D. The emulator does not support permissions.

Solution

  1. Step 1: Check manifest XML structure

    All permission tags must be inside the root <manifest> element. Placing them outside causes XML errors and app crashes.
  2. Step 2: Understand build.gradle and emulator roles

    Permissions are declared only in manifest, not build.gradle. Emulators support permissions normally.
  3. Final Answer:

    The permission tag is outside the <manifest> root element. -> Option A
  4. Quick Check:

    Permissions must be inside manifest root [OK]
Hint: Permission tags must be inside <manifest> root [OK]
Common Mistakes:
  • Adding permissions in build.gradle
  • Ignoring XML structure errors
  • Blaming emulator for permission issues
5. You want to add a new module to your Android project. Which files/folders must you update or create to integrate it properly?
hard
A. Create a new folder for the module, add a build.gradle for it, and update settings.gradle to include it.
B. Add the module folder inside app and update AndroidManifest.xml only.
C. Create a new folder and add dependencies in app/build.gradle only.
D. Add the module folder anywhere and no other changes are needed.

Solution

  1. Step 1: Create module folder and build file

    Each module needs its own folder and build.gradle to define its build settings.
  2. Step 2: Update settings.gradle

    The settings.gradle file must include the new module so Gradle knows to build it.
  3. Final Answer:

    Create a new folder for the module, add a build.gradle for it, and update settings.gradle to include it. -> Option A
  4. Quick Check:

    New module = folder + build.gradle + settings.gradle update [OK]
Hint: New module needs folder, build.gradle, and settings.gradle update [OK]
Common Mistakes:
  • Only updating AndroidManifest.xml
  • Adding module inside app folder incorrectly
  • Forgetting to update settings.gradle
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard