Android App Development

Chapter 1
Android Platform and Development Ecosystem

Certificate in Web and Android Development
Android App Development   •   Certificate

Android Platform and Development Ecosystem

Introduction

Android is a mobile operating system and software platform designed primarily for touchscreen devices, although it also supports tablets, televisions, cars, watches, embedded systems, and other form factors. Its development ecosystem combines an operating-system framework, application programming interfaces (APIs), development tools, application packaging, distribution services, and hardware environments.

For an Android developer, learning to write code is only one part of the task. A developer must also understand how an application is packaged, how it communicates with the operating system, how different Android versions affect compatibility, how Gradle builds the application, and how applications are tested on emulators and physical devices. These concepts provide the foundation for later study of activities, user interfaces, data storage, networking, security, and deployment.

Learning Objectives

By the end of this chapter, you should be able to:

  1. Describe the principal layers of Android architecture.
  2. Explain the role of application components and the Android application framework.
  3. Distinguish Android API level, Android version, compile SDK, minimum SDK, and target SDK.
  4. Identify the main tools in the Android SDK and explain their purposes.
  5. Explain the role of Gradle and build configuration files.
  6. Compare emulators with physical Android devices.
  7. Interpret the main parts of an Android Studio project.
  8. Describe the Android application development lifecycle.
  9. Apply these concepts to plan, build, test, and release a small Android application.

1. Android as a Platform

An operating system manages hardware resources and provides common services to applications. Android performs these functions through a Linux-based kernel, system services, runtime environments, and application frameworks. The Android Open Source Project (AOSP) contains much of the platform source code, while device manufacturers and ecosystem providers may add hardware drivers, services, applications, and distribution mechanisms.

Android applications are generally written in Kotlin or Java. Modern Android development commonly uses Kotlin, Android Studio, Jetpack libraries, and Gradle. Applications are compiled into packages that can be installed on compatible devices. The package contains compiled code, resources, a manifest, and metadata such as permissions and compatibility declarations.

Unlike a traditional desktop program that normally starts with a single main function, an Android application is organized around components that the operating system can start and manage. This component-based model allows an application to respond to user actions, system events, notifications, or requests from other applications.

2. Android Architecture

Android architecture is often represented as a set of cooperating layers. The layers are useful as a conceptual model, although actual platform implementation is more complex and changes over time.

Layered architecture of the Android platform Applications Application Framework and System Services Android Runtime and Core Libraries Native C/C++ Libraries Linux Kernel and Hardware Drivers
Layered architecture of the Android platform
Figure: Layered architecture of the Android platform

Figure: Conceptual layers of the Android platform.

2.1 Linux Kernel

The kernel is the lowest major software layer. It provides process and memory management, networking, security mechanisms, power management, and device-driver support. It also mediates access to hardware such as cameras, displays, sensors, audio devices, and wireless interfaces.

Applications do not normally access hardware directly. Instead, they use higher-level Android APIs. This separation improves portability and security because an application can request a capability without knowing the detailed implementation of a particular device.

2.2 Native Libraries

Android includes native libraries implemented largely in C or C++. These support functions such as graphics rendering, media playback, database operations, cryptography, and hardware-accelerated computation. Developers using ordinary Kotlin or Java APIs often use these libraries indirectly. Native development is possible through the Android Native Development Kit (NDK), but it introduces additional complexity involving memory management, processor architectures, and native debugging.

2.3 Android Runtime

The Android Runtime (ART) executes application bytecode. Kotlin and Java source code is compiled into intermediate bytecode and then transformed into a format suitable for Android execution. ART uses techniques such as ahead-of-time and just-in-time compilation to balance startup time, performance, and storage use.

The runtime also provides core language and library functionality. Garbage collection helps reclaim memory that is no longer reachable, although developers must still avoid unnecessary object creation, retained references, and resource leaks.

2.4 Application Framework and System Services

The framework provides reusable services and APIs. Examples include the activity manager, package manager, window manager, resource manager, notification manager, location services, and connectivity services. These services allow applications to perform common tasks without implementing operating-system functionality themselves.

Framework APIs also enforce application boundaries. For example, an application requesting location data must use supported permissions and APIs, and the operating system may require the user to approve access.

2.5 Applications

The upper layer contains system applications and third-party applications. Applications use framework APIs, resources, and declared components. A well-designed application should rely on documented APIs rather than assumptions about a specific manufacturer’s device or internal implementation.

3. Application Components and the Manifest

The Android application model is based on components. The four principal component types are activities, services, broadcast receivers, and content providers.

Activities

An activity represents a user-facing screen or a focused interaction. An application may contain several activities, although modern applications often use a single activity with multiple composable screens. Activities have a lifecycle controlled by the operating system. They can be created, started, resumed, paused, stopped, and destroyed as the user navigates or as resources become constrained.

An activity should not assume that it will remain in memory indefinitely. Important state should be saved or stored in an appropriate model so that the interface can be reconstructed after configuration changes or process recreation.

Services

A service performs work that may continue without a directly visible user interface. Examples include playing audio, synchronizing data, or processing a task. Current Android versions impose restrictions on background execution to protect battery life and privacy. Long-running visible work may require a foreground service, while deferrable work is often better handled with scheduled background-work APIs.

Broadcast Receivers

A broadcast receiver responds to broadcast messages from the system or applications. Examples include changes in connectivity or completion of a system event. Receivers should perform short operations and delegate substantial work to an appropriate background mechanism.

Content Providers

A content provider presents structured data through a standardized interface. It can support controlled data sharing between applications. Although many applications do not implement their own provider, they may use providers for contacts, media, or other shared data.

The Android Manifest

The manifest is an essential application description file. It can declare components, permissions, supported features, application metadata, and compatibility information. The operating system reads the manifest before installing or launching the application.

A permission declaration does not always grant access. For sensitive permissions, the application may need both a manifest declaration and a runtime request, and the user may deny the request. Good practice is to request only necessary permissions, explain their purpose, and degrade gracefully when access is refused.

4. API Levels and Compatibility

An Android API level is an integer identifying a particular set of available platform APIs. Android releases also have names or version numbers, but API level is the technical value used in build and compatibility configuration.

Three SDK settings are especially important:

SettingMeaningPractical effect
compileSdkPlatform APIs used to compile the source codeDetermines which API symbols the compiler can recognize
minSdkOldest supported API levelDetermines the minimum platform on which installation is permitted
targetSdkAPI behavior level the application targetsSignals that the application has been tested against the behavior expectations of that level

These settings are related but not interchangeable. A project can compile against a recent SDK while supporting older devices through a lower minimum SDK. Code that uses a newer API must be protected by version checks or replaced with a compatibility library when older devices are supported.

For example, conceptually, code may follow this pattern:

if the device API level is at least the required level:
    use the newer platform API
else:
    use an alternative implementation

Compatibility has several dimensions: API availability, behavior changes, screen sizes, processor architectures, permissions, manufacturer variations, and hardware features. Testing only on the newest phone is therefore inadequate.

5. Android SDK and Development Tools

The Software Development Kit (SDK) is a collection of platforms, libraries, command-line tools, build tools, debugging utilities, and emulator components.

Important tools include:

  • Android Studio: The integrated development environment used to edit code, design interfaces, inspect projects, run tests, and analyze performance.
  • SDK Manager: Installs and updates platform packages, build tools, platform tools, and emulator images.
  • Platform tools: Include utilities such as Android Debug Bridge (ADB), which communicates with connected devices and emulators.
  • Build tools: Compile, package, align, and sign application artifacts.
  • Android Emulator: Runs a virtual device configuration on a computer.
  • Logcat: Displays system and application log messages useful for diagnosis.
  • Profiler tools: Help inspect CPU activity, memory use, network traffic, and energy-related behavior.
  • Device File Explorer and debugger: Assist with inspecting files and stepping through code.

ADB can install an application, launch activities, copy files, collect logs, and execute shell commands. USB debugging on a physical device should be enabled only when appropriate, and developer devices should be protected because debugging access can expose application data.

6. Gradle and the Android Build Process

Gradle is a build automation system. Android projects use the Android Gradle Plugin, which adds Android-specific tasks such as resource processing, manifest merging, code compilation, packaging, testing, and signing.

A build script describes plugins, dependencies, SDK settings, build types, product flavors, and other configuration. Gradle resolves libraries and constructs reproducible build variants. A build variant is commonly formed from a build type, such as debug or release, and, where applicable, a product flavor.

A simplified build sequence is:

  1. Read project and module configuration.
  2. Resolve plugins and dependencies.
  3. Compile Kotlin or Java source code.
  4. Process resources and merge manifests.
  5. Run unit and instrumented tests as configured.
  6. Transform and optimize code and resources.
  7. Package the application.
  8. Sign the output and produce an installable artifact.

The application module commonly contains a build.gradle.kts or build.gradle file. A project-level configuration manages shared settings, while settings.gradle.kts identifies modules and repositories. Modern projects may use version catalogs to centralize dependency versions.

Gradle improves repeatability, but dependencies must be managed carefully. A library should be selected for maintenance quality, compatibility, license suitability, security, and actual need. Unnecessary dependencies increase application size and attack surface.

7. Emulators and Physical Devices

An emulator is software that models an Android device. An Android Virtual Device (AVD) specifies characteristics such as device profile, screen dimensions, API level, architecture, memory, storage, and system image. Emulators are valuable for repeatable testing, screenshots, automated tests, and configurations that are not physically available.

Physical devices reveal issues that emulators may not reproduce accurately, including camera behavior, sensors, thermal throttling, manufacturer customizations, variable network conditions, battery constraints, and real touch interaction. A practical testing strategy uses both environments.

EmulatorPhysical device
Fast to reset and reproduceRepresents real hardware behavior
Supports many API and screen configurationsReveals manufacturer and sensor differences
May have artificial performance or graphics behaviorTesting may be slower and hardware access limited
Useful for automationEssential for final usability and hardware checks

Testing should include different screen sizes, orientations, font scales, network conditions, permission choices, and process-recreation scenarios. Accessibility testing should include screen readers, touch targets, contrast, and scalable text.

8. Android Studio Project Structure

A typical Android project contains one or more modules. The application module commonly includes the following directories and files:

ItemPurpose
src/main/java or src/main/kotlinApplication source code
src/main/resResources such as layouts, drawables, strings, colors, and menus
src/main/AndroidManifest.xmlComponents, permissions, and application metadata
src/testLocal unit tests running on the development machine
src/androidTestTests running on an Android device or emulator
build.gradle(.kts)Module build configuration
settings.gradle(.kts)Project modules and repository settings
gradle.propertiesGradle properties and configuration values
build/Generated outputs; normally not edited manually

Resource qualification allows Android to select suitable resources for conditions such as language, screen density, orientation, or smallest width. Text should normally be stored in string resources rather than hard-coded in code, because this supports translation and consistent maintenance.

A source-control system should track source files and configuration but generally exclude generated build output, local machine settings, and secrets. Signing credentials and API keys must not be committed to a public repository.

9. The Android Application Development Lifecycle

Android development is an iterative lifecycle rather than a one-time sequence.

Requirements and Feasibility

The developer first defines the users, problem, platform constraints, required features, privacy implications, and success criteria. Feasibility includes checking whether required hardware, APIs, data sources, and performance targets are realistic.

Design and Architecture

The team designs user flows, interface states, data models, and navigation. A suitable architecture separates presentation, state, domain logic, and data access. Separation improves testing and reduces the risk that a user interface class becomes responsible for every concern.

Implementation

Developers create project modules, configure Gradle, implement screens and components, add resources, and use version control. Small, understandable changes are easier to review and debug than large unstructured changes.

Build and Verification

The application is compiled and tested. Local unit tests can verify logic quickly, while instrumented tests verify behavior on Android. Static analysis, lint checks, and code review identify defects before release.

Testing and Quality Assurance

Testing should cover normal behavior, invalid input, interruptions, rotation or resizing, offline conditions, permissions, accessibility, security, and supported API levels. Performance testing should examine startup, scrolling, memory, battery, and network use.

Release Preparation

A release build differs from a debug build. It should be optimized as appropriate, signed with controlled credentials, configured with production endpoints, and checked for privacy disclosures, permissions, crashes, and compatibility. Release artifacts may be distributed through an application store, managed enterprise deployment, or direct controlled installation.

Monitoring and Maintenance

After release, developers respond to crash reports, user feedback, operating-system changes, security advisories, and library updates. Maintenance is part of the lifecycle, not an optional final step.

10. Applied Case: A Campus Shuttle Application

Background

This illustrative case concerns a small application that shows campus shuttle routes, service notices, and an estimated arrival message.

Problem

Students need information during travel, but connectivity is unreliable and location access is sensitive. The application must support several Android versions and remain useful when live data is unavailable.

Analysis

The team identifies route browsing as a core offline feature and live arrival information as an optional network feature. Location is not essential because users can select a campus stop manually. Avoiding unnecessary location permission reduces privacy risk and simplifies approval.

Approach and Solution

The team selects a current compile SDK, defines a realistic minimum SDK based on the institution’s devices, and targets a current behavior level. Route data is stored locally, while a repository coordinates local data and a network service. The interface presents loading, success, empty, error, and stale-data states. A scheduled background task refreshes data when appropriate rather than continuously polling.

The team tests on an emulator with small and large screens, a physical low-cost device, and a recent device. Tests include no network, denied permissions, rotation, process recreation, and invalid server responses. Gradle separates debug configuration from release configuration, and secret service credentials are kept outside source control.

Outcome

The resulting design provides useful route information offline, limits permissions, handles failure visibly, and reduces dependence on one device or one API level. The application is easier to maintain because data access, presentation, and build configuration are separated.

Learning Points

The case demonstrates that platform knowledge affects product decisions. API-level planning influences compatibility; architecture affects testability; permissions affect trust; and build configuration affects reliable delivery.

11. Challenges, Ethics, and Best Practices

Android fragmentation means that devices differ in API level, hardware, display, manufacturer software, memory, and performance. Developers should use documented APIs, test representative device classes, and avoid assuming that all devices have a feature.

Privacy is a core responsibility. Applications should collect the minimum necessary data, explain collection clearly, protect data in transit and at rest where appropriate, and provide meaningful choices. Sensitive data should not be written casually to logs. Permissions must be requested in context rather than as a general attempt to maximize access.

Security practices include validating external input, using secure communication, protecting authentication tokens, updating dependencies, applying least privilege, and avoiding hard-coded secrets. Accessibility is also an ethical and professional requirement: interfaces should support assistive technologies, readable text, sufficient contrast, and usable touch targets.

Artificial intelligence may assist developers with code completion, test generation, documentation, and debugging suggestions. However, generated code must be reviewed for incorrect APIs, insecure practices, licensing concerns, privacy leakage, and poor maintainability. Responsibility for the released application remains with the development team.

Contemporary Android development increasingly emphasizes declarative user interfaces, modular architecture, automated testing, continuous integration, privacy-aware design, and adaptive layouts for phones, tablets, foldables, cars, watches, and large screens. These trends do not remove the need to understand the platform fundamentals described in this chapter.

Chapter Summary

Android is a layered operating-system platform consisting conceptually of the Linux kernel, native libraries, Android Runtime, framework services, and applications. Applications are organized into activities, services, broadcast receivers, and content providers, with their capabilities and metadata declared in the manifest.

API level determines the platform API set. compileSdk, minSdk, and targetSdk serve different purposes and must be planned deliberately. The Android SDK supplies platforms, build tools, platform tools, emulators, debuggers, and profilers. Gradle automates compilation, resource processing, testing, packaging, and signing through configurable build variants.

Android Studio projects contain source code, resources, manifests, tests, and build configuration. Emulators provide repeatable virtual environments, while physical devices expose real hardware and manufacturer behavior. The development lifecycle progresses from requirements and design through implementation, testing, release, monitoring, and maintenance. Professional Android development also requires attention to privacy, security, accessibility, compatibility, dependency management, and responsible use of AI-assisted tools.

Key Terms

Android: A mobile operating system and application platform.

API level: An integer identifying a set of Android platform APIs.

AOSP: Android Open Source Project, containing major portions of Android’s source code.

Android Runtime (ART): The execution environment for Android application code.

Activity: A component representing a user-facing interaction or screen.

Service: A component for work that may continue without a directly visible interface.

Broadcast receiver: A component that responds to broadcast messages.

Content provider: A standardized interface for sharing structured data.

Manifest: An XML declaration of application components, permissions, and metadata.

SDK: Software Development Kit containing Android development platforms and tools.

ADB: Android Debug Bridge, a tool for communicating with devices and emulators.

AVD: Android Virtual Device configuration used by the emulator.

Gradle: A build automation system used to configure and produce Android artifacts.

Android Gradle Plugin: Gradle plugin that supplies Android-specific build tasks.

compileSdk: SDK platform used to compile application code.

minSdk: Lowest Android API level supported by an application.

targetSdk: API behavior level against which an application is designed and tested.

Build variant: A particular combination of build type and, where applicable, product flavor.

Resource: Externalized application content such as text, images, layouts, or values.

Instrumentation test: A test that runs on an Android device or emulator.

Review Questions

Short Answer Questions

  1. What is the purpose of the Android Runtime?
  2. Name the four principal Android application component types.
  3. What does minSdk specify?
  4. Why are emulators useful during Android development?
  5. What is the role of the Android manifest?

Long Answer Questions

  1. Explain the major layers of Android architecture and how they support application execution.
  2. Compare activities, services, broadcast receivers, and content providers.
  3. Distinguish compileSdk, minSdk, and targetSdk, giving a practical example of why each matters.
  4. Describe how Gradle contributes to the Android build process.
  5. Explain the major stages of the Android application development lifecycle.

Analytical / Application Questions

  1. A campus application must support older phones, work when offline, and avoid unnecessary permissions. Propose a platform and testing strategy, explaining your decisions.
  2. An application works on an emulator but crashes on a low-memory physical device. Identify possible causes and describe a systematic debugging approach.
  3. A team wants to add a library that requests several permissions and has not been updated recently. Analyze the technical, security, privacy, and maintenance factors that should guide the decision.

Multiple Choice Questions with Answers

Question 1

Which Android layer is primarily responsible for process management, memory management, and device drivers?

A. Applications

B. Android Runtime

C. Linux kernel

D. Application framework

Correct Answer: C. Linux kernel

Question 2

Which component normally represents a user-facing screen or focused interaction?

A. Activity

B. Content provider

C. Broadcast receiver

D. Service

Correct Answer: A. Activity

Question 3

What does minSdk define?

A. The newest API used by the compiler

B. The oldest Android API level supported

C. The behavior level targeted by the application

D. The version of Gradle installed

Correct Answer: B. The oldest Android API level supported

Question 4

What is the primary purpose of compileSdk?

A. To determine the oldest installable device

B. To select the application store category

C. To identify the platform APIs available to the compiler

D. To specify the application signing key

Correct Answer: C. To identify the platform APIs available to the compiler

Question 5

Which tool communicates with connected Android devices and emulators?

A. ADB

B. ART

C. AVD

D. Lint

Correct Answer: A. ADB

Question 6

What does Gradle primarily provide in an Android project?

A. Physical device sensors

B. Build automation and dependency configuration

C. A replacement for the Android operating system

D. User authentication for applications

Correct Answer: B. Build automation and dependency configuration

Question 7

Which statement correctly compares an emulator and a physical device?

A. Only physical devices can run automated tests

B. Emulators are useful for repeatable configurations, while physical devices reveal real hardware behavior

C. Physical devices cannot test cameras or sensors

D. Emulators always reproduce manufacturer-specific behavior exactly

Correct Answer: B. Emulators are useful for repeatable configurations, while physical devices reveal real hardware behavior

Question 8

Where are Android application permissions and component declarations commonly specified?

A. The manifest

B. The Gradle cache

C. The emulator snapshot

D. The Logcat buffer

Correct Answer: A. The manifest

Question 9

Why should code using a newer Android API be protected when older API levels are supported?

A. Older devices may not provide that API

B. Newer APIs always require a service component

C. The manifest cannot contain permissions

D. Gradle cannot compile Kotlin code

Correct Answer: A. Older devices may not provide that API

Question 10

Which is the best practice for application permissions?

A. Request every available permission during startup

B. Store permission decisions in plain-text logs

C. Request only necessary permissions and explain their purpose

D. Assume a manifest declaration guarantees user approval

Correct Answer: C. Request only necessary permissions and explain their purpose

Android App Development
Chapter 1 of 15