Exploring Android Project Directory Structure and Changing Attributes

Exploring Android Project Directory Structure and Changing Attributes


1. Project Setup in Android Studio

A new Android project is created using Android Studio (latest stable version) with the following configuration:

  • Project Name: DirectoryStructureDemo

  • Activity Type: Empty Activity

  • Activity Name: MainActivity

  • Layout Name: activity_main.xml

  • Language: Java

  • Minimum SDK: API 21 (Android 5.0)

After project creation, Android Studio generates a predefined directory structure that organizes application code, resources, and build configuration files.


2. Exploring Android Project Directory Structure

Android Studio provides multiple views to understand the project organization. The two most important views are Android View and Project View.


2.1 Android View

The Android View is a simplified and logical representation designed for beginners. It groups files based on their purpose rather than their physical location.

Main components visible in Android View:

a) manifests

  • Contains AndroidManifest.xml

  • Defines essential information about the app such as:

    • Package name

    • Application components (activities)

    • Permissions

    • App theme and icon

b) java

  • Contains all Java source files

  • Organized according to the package name

  • Includes MainActivity.java and other activity or helper classes

c) res

  • Stores all non-code resources

  • Subdirectories include:

    • layout – XML UI layouts

    • values – strings, colors, themes, styles

    • drawable – images and vector assets

    • mipmap – app launcher icons

d) Gradle Scripts

  • Contains build configuration files

  • Controls SDK versions, dependencies, and application ID


2.2 Project View

The Project View shows the actual folder hierarchy as stored on disk.
It is useful for understanding how Android internally organizes files and for advanced configuration.


3. Changing Attributes in Directory Structure

3.1 AndroidManifest.xml (manifests directory)

The AndroidManifest.xml file defines core application-level attributes.

Common attributes and their impact:

  • package

    • Unique identifier of the application

    • Used by Android OS and Play Store

    • Changing it changes the app’s identity

  • android:label

    • Defines the app name displayed on the launcher and title bar

    • Usually linked to @string/app_name

  • android:icon

    • Sets the launcher icon

    • Refers to files in the mipmap directory

  • android:theme

    • Applies a theme to the entire application

    • Controls colors, fonts, and UI style globally

Any change in the manifest affects how the application behaves at the system level.


3.2 Layout File: activity_main.xml (res/layout)

This file defines the user interface of MainActivity.

Common layout attributes:

  • android:layout_width

    • Specifies width of a view (match_parent, wrap_content)

  • android:layout_height

    • Specifies height of a view

  • android:orientation

    • Used in LinearLayout

    • Can be vertical or horizontal

  • android:background

    • Sets background color or drawable

Example modification:

  • Add a TextView or Button

  • Change text size, text color, and background color

These changes directly affect the UI appearance on the emulator.


3.3 Strings Resource: strings.xml (res/values)

This file stores all text used in the application.

Key points:

  • Centralized text management

  • Supports localization (multiple languages)

  • Prevents hardcoding of strings in layout and Java files

Example:

  • Modify app_name

  • Add a new string for a TextView

Hardcoded strings should be avoided because they:

  • Reduce maintainability

  • Break internationalization support

  • Cause lint warnings in Android Studio


3.4 Colors Resource: colors.xml (res/values)

This file defines reusable color values.

Steps:

  • Define a new color (e.g., primary or custom color)

  • Reference it in layouts or themes using @color/colorName

Benefits:

  • Consistent color usage

  • Easy theme customization

  • Centralized UI control


3.5 Themes and Styles: themes.xml / styles.xml

Theme files control the overall look and feel of the application.

Common attributes:

  • Primary color

  • Status bar color

  • Background color

  • Text appearance

Impact:

  • A single theme change reflects across all activities

  • Ensures visual consistency

  • Reduces repeated styling code


4. Java Source Code: MainActivity.java

The java directory contains application logic.

Key observations:

  • MainActivity extends AppCompatActivity

  • setContentView(R.layout.activity_main) links Java code with XML layout

  • R class is auto-generated and connects code with resources

No complex logic is required for this task; the focus is understanding how resources are referenced.


5. Gradle Files

5.1 Project-level build.gradle

  • Defines repositories and global configurations

  • Affects all modules in the project

5.2 Module-level build.gradle

  • Defines:

    • applicationId

    • minSdk

    • targetSdk

    • versionCode and versionName

These attributes control:

  • Device compatibility

  • App identity

  • Build behavior

Dependencies should not be modified unnecessarily in academic practicals.


6. Emulator Execution (Medium Phone AVD)

The application is executed on a Medium Phone AVD.

Observed effects:

  • Changed android:label reflects as app name

  • Modified layout and colors appear in UI

  • Theme changes affect status bar and overall design

This confirms the relationship between directory-level attribute changes and runtime behavior.


Learning Outcome Achievement (LLO 3.1)

After completing this task, students are able to:

  • Explore Android project directory structure

  • Understand the purpose of major directories

  • Modify attributes in manifest, resources, and Gradle files

  • Observe the effect of changes on the emulator

  • Correlate project structure with application behavior


This experiment demonstrates foundational Android project awareness and directory-level configuration skills required for practical examinations and industry-ready development.

Popular posts from this blog