DEV Community

Cover image for Introduction to Android Development
Madhav Ganesan
Madhav Ganesan

Posted on

Introduction to Android Development

Android Debug Bridge (adb)

It is a versatile command-line tool that enables developers to communicate with an Android device or emulator for debugging and other tasks. It is a key component of the Android SDK and allows developers to perform various operations on Android devices such as installing apps, running shell commands, copying files, and debugging apps.

Key Terms

Flashing

It refers to the process of writing a file (usually a firmware, custom ROM, kernel, recovery image, or mod) directly to your device's internal storage, typically to a specific partition (e.g., system, recovery, boot).

Examples of files you flash:

  • Custom ROMs (e.g., Resurrection Remix)
  • Recovery tools (e.g., TWRP)
  • Root tools (e.g., Magisk)

Rooting

  • It is the process of gaining administrator or superuser access to the Android operating system, essentially unlocking the full control of the device.
  • This gives users access to the root file system and allows them to make system-level changes, install specialized apps, and tweak the operating system.
  • You can install modified versions of Android (like LineageOS) to get features or performance improvements not offered by the official version.
  • Rooting can enable you to change the processor's clock speeds for better performance or battery savings.

Bloatware

  • It refers to pre-installed software or applications on a device, typically added by the device manufacturer, carrier, or vendor. These apps often take up storage space, consume system resources, and cannot easily be uninstalled or removed by the user, especially on unrooted devices.

Bricking

  • It refers to a situation where an electronic device, such as a smartphone, tablet, or any other hardware, becomes completely unusable due to corrupted or damaged firmware or software.

Types of Bricking:

Soft Brick:
A soft-bricked device is semi-functional and can often be recovered.

Hard Brick:
A hard-bricked device is completely unresponsive and does not power on or show any signs of life.

Decompile

It is the process of converting compiled machine code (binary or bytecode) back into a higher-level programming language code that is more human-readable.

Code obfuscation

  • It is the process of deliberately making source code or compiled code more difficult to read and understand, while preserving its functionality. It is primarily used to protect intellectual property and prevent unauthorized reverse engineering, tampering, or copying of software.
  • Tools like ProGuard or R8 in Android can obfuscate both the Java code and XML resources. If XML files are obfuscated, the layout references in the decompiled APK might appear as unreadable strings or corrupted data.

DEX (Dalvik Executable)

  • It is a format used by the Android operating system to execute applications. It is the compiled bytecode file that Android devices run on the Dalvik or ART (Android Runtime) virtual machines.
  • It is conceptually similar to Java bytecode

Key Components

AndroidManifest.xml

This is the core configuration file of the Android app.

  • App's package name.
  • Permissions required (e.g., camera, location).
  • Declared components: Activities, Services, Broadcast Receivers, Content Providers.
  • App’s theme and configuration.

res/ Folder (Resources)

It contains resources used by the app such as layouts, drawables, and strings.

assets/ Folder

  • It contains additional resources and data files bundled with the app.
  • Files like .json, .html, .txt, or custom formats used by the app.

smali/ Folder

  • It contains the smali files, which are the disassembled DEX bytecode.
  • Smali is an intermediate language used for representing DEX files.
  • The folder structure mirrors the package structure of the app (e.g., com/example/app for com.example.app).
  • Each .smali file represents a class, and it includes low-level instructions similar to assembly code.
  • Smali code is the human-readable representation of Dalvik bytecode, which is used in Android applications. It is an assembly-like language that is generated when an APK file is decompiled using tools like APKTool.
  • APK is nothing but a file format whose backronym is “Android Operating System Package

Comments

  • When an Android app is compiled from source code, the Java/Kotlin files are first converted into bytecode (Java .class files), and then these .class files are transformed into DEX files using a tool called dx (for older versions of Android) or d8 (used in newer Android versions).

Mipmaps

  • It refers to a set of image resources designed for various screen densities. They are commonly used for app launcher icons to ensure that the icon appears sharp and clear across all devices, regardless of screen resolution.
  • The mipmap directory allows the Android system to select the best-suited launcher icon size based on the device's screen density.

Image description

Image description

Android Support Library (or AndroidX libraries)
These libraries are pre-built and can be included in your project automatically by adding the appropriate dependencies in your build.gradle file.
When you create a new project in Android Studio, some basic AndroidX libraries are already included, such as androidx.appcompat for backward-compatible UI components.

Package in Android

  • It is a way of organizing classes and resources in a structured manner. It’s essentially a namespace to avoid name conflicts and group related components.
  • Android apps are identified by their package names, not just by their app name.
  • A unique package name ensures there are no conflicts between apps on the Google Play Store or device.
  • Gradle can be compared to Webpack in the sense that both are build tools
  • The structure com.example.myapp is based on a reversed domain name.
  • Ex.
com.google.android.apps.maps (Google Maps)
com.facebook.katana (Facebook app)
Enter fullscreen mode Exit fullscreen mode
  • How to know the package name of an application in the playstore?
https://play.google.com/store/apps/details?id=com.example.appname&hl=en_IN
Enter fullscreen mode Exit fullscreen mode

Gradle

It is a build system used in Android development. It automates tasks like:

  • Compiling the code into .apk or .aab.
  • Resolving dependencies (e.g., downloading libraries from repositories).
  • Managing project configurations for different build variants (e.g., debug, release).

How Gradle Works:
Build Script: Each Android project has a build.gradle file (or multiple files in larger projects).
Gradle reads the script, processes the configuration, and builds the app accordingly

build.gradle is a script file written in Groovy or Kotlin that contains instructions for Gradle on how to build your app

build.gradle (App-Level)

plugins {
    id 'com.android.application'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.example.myapp"
        minSdk 21
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Enter fullscreen mode Exit fullscreen mode

build.gradle (Project-Level)

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
Enter fullscreen mode Exit fullscreen mode

Folder Structure

MyProject/
│
├── app/
│   ├── build.gradle
│   ├── src/
│   │   ├── androidTest/
│   │   │   └── java/
│   │   │       └── com.example.myapp/   # Instrumented test files
│   │   ├── main/
│   │   │   ├── java/
│   │   │   │   └── com.example.myapp/   # App source code
│   │   │   ├── res/
│   │   │   │   ├── drawable/            # Images and drawables
│   │   │   │   ├── layout/              # UI layouts (XML)
│   │   │   │   ├── values/              # Strings, styles, themes
│   │   │   │   ├── mipmap/              # Launcher icons
│   │   │   │   ├── menu/                # Menus (optional)
│   │   │   │   ├── anim/                # Animations (optional)
│   │   │   │   └── raw/                 # Raw assets (optional)
│   │   │   └── AndroidManifest.xml
│   │   └── test/
│   │       └── java/
│   │           └── com.example.myapp/   # Local unit tests
│   └── proguard-rules.pro               # ProGuard and R8 rules for obfuscation
│
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
│
├── build/
│   └── outputs/                         # Compiled APKs
├── .gradle/
├── .idea/
├── build.gradle
├── settings.gradle
├── gradle.properties
├── local.properties
└── .gitignore
Enter fullscreen mode Exit fullscreen mode

AndroidTest folder

It contains instrumented test cases that run on a physical device or emulator.

Main Folder

It contains the main source code and resources for your app. This is the primary folder where your app logic resides.

  • java: It contains Java/Kotlin files, such as activities, fragments, and other classes.
  • res: It contains non-code resources like layouts, drawables, strings, themes, etc.
  • AndroidManifest.xml: The configuration file for your app, defining app components, permissions, etc.

Test Folder

It contains local unit test cases that run on your development machine (not on an Android device).

System image

It refers to a pre-configured Android operating system environment that is used by the Android Emulator to simulate the functionality of a physical Android device. It includes the core components and services required for running Android apps, allowing developers to test their apps in a virtualized Android environment.

Dex to Java Decompiler
https://github.com/skylot/jadx?tab=readme-ov-file
Decompiler
https://apktool.org/docs/install/
Sign an APK
https://github.com/techexpertize/SignApk

Stay Connected!
If you enjoyed this post, don’t forget to follow me on social media for more updates and insights:

Twitter: madhavganesan
Instagram: madhavganesan
LinkedIn: madhavganesan

Top comments (0)