← Back to Tutorials Chapter 2

Environment Setup

Prerequisites

Installing Android Studio

  1. Download Android Studio from developer.android.com/studio
  2. Run the installer and follow the setup wizard
  3. Select "Standard" installation type to install the latest SDK
  4. Choose a dark or light theme
  5. Wait for the SDK components to download

Android SDK Manager

The SDK Manager lets you install and manage Android SDK platforms, build tools, and system images.

// Key SDK components to install:
// - Android SDK Platform (latest API level)
// - Android SDK Build-Tools
// - Android Emulator
// - Intel HAXM or Windows Hyper-V for emulator acceleration
// - System images for different API levels

// Via command line (sdkmanager):
sdkmanager "platforms;android-34"
sdkmanager "build-tools;34.0.0"
sdkmanager "system-images;android-34;google_apis;x86_64"
sdkmanager --licenses

Android Studio Overview

Project Structure

MyAndroidApp/
  app/
    src/
      main/
        java/com/example/app/   # Source code (Kotlin/Java)
        res/
          drawable/              # Images and drawable resources
          layout/                # XML layout files
          mipmap/                # Launcher icons
          values/                # Strings, colors, themes
        AndroidManifest.xml      # App configuration
      test/                      # Unit tests
      androidTest/               # Instrumented tests
    build.gradle.kts             # App-level build config
  build.gradle.kts               # Project-level build config
  settings.gradle.kts            # Project settings
  gradle.properties              # Gradle properties

Build System (Gradle)

// app/build.gradle.kts
plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
}

android {
    namespace = "com.example.myapp"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.myapp"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            proguardFiles(getDefaultProguardFile("proguard-android.txt"))
        }
    }
}

dependencies {
    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    testImplementation("junit:junit:4.13.2")
}

Setting Up the Emulator

# Create an AVD (Android Virtual Device) via command line
avdmanager create avd -n Pixel6_API34 -k "system-images;android-34;google_apis;x86_64" -d pixel_6

# Start the emulator
emulator -avd Pixel6_API34

# Or use Android Studio:
# Tools > AVD Manager > Create Virtual Device
Exercise: Install Android Studio, create a new project with Kotlin, set up an emulator with API 34 (Pixel 6 profile), and run the default "Hello World" app on the emulator. Take a screenshot of the running app.