Android Studio Setup & First App

Android Development Fundamentals
Course 1 ยท Chapter 1 ยท Android Studio Setup & First App

๐Ÿ“ฑ Android Studio Setup & First App

Both Kotlin courses covered the language; this course covers building actual Android apps with it. This chapter is pure tooling and orientation โ€” installing Android Studio, touring the IDE, understanding what a generated project actually contains, and running a first app on an emulator. Nothing here is Kotlin-specific yet; it's the ground everything else in this course stands on.

โฌ‡๏ธ Installing Android Studio

Android Studio is Google's official IDE for Android development, built on JetBrains' IntelliJ IDEA โ€” the same underlying IDE platform used for pure Kotlin/Java development, with an entire layer of Android-specific tooling added on top (layout editor, emulator management, APK analysis, and more).

  • Download from developer.android.com/studio โ€” it bundles a compatible JDK, so a separate Java installation usually isn't required.
  • The installer offers a "Standard" setup type on first run โ€” this downloads the Android SDK, a default emulator system image, and standard build tools. Accept the defaults unless there's a specific reason not to.
  • First launch takes a few minutes while the SDK and build tools finish downloading โ€” this only happens once.

๐Ÿ†• Creating Your First Project

From the Android Studio welcome screen, choose New Project, then pick a template. For this course, choose Empty Views Activity โ€” not "Empty Activity," which defaults to Jetpack Compose (covered later, in Course 2). Starting with the traditional View/XML system first, before Compose, matches how this course builds up: Chapter 3 covers XML layouts directly.

Name & Package Name

The project name is just a label. The package name (e.g. com.philip.myfirstapp) is a reverse-domain identifier that must be globally unique if the app is ever published โ€” it can't be easily changed later, so it's worth getting right from the start.

Minimum SDK

The oldest Android version the app will still run on, chosen from a dropdown showing the percentage of active devices each option covers. A higher minimum means fewer devices supported but access to newer APIs without extra compatibility checks.

๐Ÿงญ A Tour of the IDE

Project View (left)

Browses the project's files โ€” defaults to "Android" view, which groups files by purpose (manifests, java, res) rather than mirroring the raw folder structure exactly. Switch to "Project" view to see the real file layout on disk.

Editor (center)

Standard IntelliJ-style code editing โ€” the same autocomplete, refactoring tools, and inspections as any JetBrains IDE, plus a live XML layout preview when editing a layout file.

Logcat (bottom)

The running app's log output in real time โ€” every println-equivalent (Log.d(...), covered next chapter), crashes, and system messages, filterable by app process and log level.

Device Manager

Where virtual devices (emulators) are created and managed โ€” covered in its own section below.

๐Ÿ“‚ What a Generated Project Actually Contains

MyFirstApp/ โ”œโ”€โ”€ app/ โ”‚ โ”œโ”€โ”€ manifests/ โ”‚ โ”‚ โ””โ”€โ”€ AndroidManifest.xml # app metadata: package, permissions, activities, launcher icon โ”‚ โ”œโ”€โ”€ java/ โ”‚ โ”‚ โ””โ”€โ”€ com/philip/myfirstapp/ โ”‚ โ”‚ โ””โ”€โ”€ MainActivity.kt # your first Kotlin file โ€” the app's entry-point screen โ”‚ โ”œโ”€โ”€ res/ โ”‚ โ”‚ โ”œโ”€โ”€ layout/ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ activity_main.xml # the XML that defines what MainActivity's screen looks like โ”‚ โ”‚ โ”œโ”€โ”€ values/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ strings.xml # text content, kept separate from layout/code โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ colors.xml # named color values โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ themes.xml # app-wide styling โ”‚ โ”‚ โ””โ”€โ”€ drawable/ # images and vector icons โ”‚ โ””โ”€โ”€ build.gradle.kts # APP-level build config โ€” dependencies, SDK versions โ””โ”€โ”€ build.gradle.kts # PROJECT-level build config โ€” shared across all modules

AndroidManifest.xml is worth singling out: it's the file the Android OS itself reads to know what your app is โ€” which screens (Activitys) exist, which one launches first, what permissions it needs, what its icon and name are. Nothing runs on a real device or emulator without a correct manifest.

โš  res/ Files Are Referenced by Name, Not Imported

A string in strings.xml named app_name is referenced from Kotlin as R.string.app_name and from XML as @string/app_name โ€” R is an auto-generated class mapping every resource to a stable ID. This indirection (separate text/color/dimension files instead of hardcoded values in code) is deliberate: it's what makes translations, dark mode, and different screen sizes possible without touching application logic.

๐Ÿ˜ Gradle Basics

Gradle is Android's build system โ€” it compiles Kotlin/Java code, packages resources, resolves dependencies, and produces the final installable app package (an APK or AAB). The two build.gradle.kts files serve different scopes:

// app/build.gradle.kts โ€” this module's specific configuration android { namespace = "com.philip.myfirstapp" compileSdk = 34 defaultConfig { applicationId = "com.philip.myfirstapp" minSdk = 24 targetSdk = 34 } } dependencies { implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") }

Gradle vs npm โ€” A Familiar Shape

npm (package.json)Gradle (build.gradle.kts)
Declares dependencies"dependencies": { "express": "^4.18.0" }implementation("androidx.core:core-ktx:1.12.0")
Install/sync commandnpm install"Sync Now" (automatic on file changes)
Where deps come fromnpm registryMaven repositories (Google's, Maven Central)
Build/run commandnpm run buildRun โ–ถ in the IDE, or ./gradlew build

The dependency-declaration idea from Node.js Fundamentals (Course 1, Chapter 2) transfers directly โ€” implementation(...) lines are Gradle's equivalent of entries in package.json's dependencies, just referencing Maven coordinates (group:artifact:version) instead of npm package names.

๐Ÿ“ฒ The Emulator: Running Your First App

The Device Manager creates and manages Android Virtual Devices (AVDs) โ€” emulated phones/tablets that run on the development machine:

  1. Open Device Manager (usually a phone-shaped icon in the toolbar or right-hand panel).
  2. Click Create Device, pick a phone definition (e.g. Pixel 7), and select a system image (an Android version) โ€” Android Studio may need to download the image first.
  3. Once created, click the green Run โ–ถ button with the new AVD selected as the target โ€” Android Studio builds the app, boots the emulator (first boot takes a minute or two), installs the app, and launches it automatically.

The default Empty Views Activity template shows a single screen with "Hello World!" text โ€” that text lives in activity_main.xml, not hardcoded in MainActivity.kt, following the resource-separation pattern from the warning box above.

๐Ÿ’ก A Physical Device Works Too, and Is Often Faster

Enabling Developer Options and USB debugging on an Android phone, then connecting it by USB, lets it appear as a run target alongside emulators โ€” often noticeably faster than emulation, and useful for testing on real hardware. Not required for this course, but worth knowing exists.

๐Ÿ’ป Coding Challenges

Challenge 1: Create and Run a Project

Create a new project using the Empty Views Activity template, name it anything you like, set the minimum SDK to API 24, create an AVD, and run the app successfully โ€” confirming "Hello World!" appears on the emulator screen.

Goal: Confirm the full toolchain (Android Studio โ†’ Gradle โ†’ emulator) works end to end.

โ†’ Solution

Challenge 2: Edit a String Resource

Open res/values/strings.xml, find the string used by the "Hello World!" text (check activity_main.xml for the @string/... reference to identify its name), change its value, and re-run the app to confirm the new text appears โ€” without touching MainActivity.kt or the layout XML at all.

Goal: Get comfortable with the res/ resource-reference pattern by using it, not just reading about it.

โ†’ Solution

Challenge 3: Add a Dependency

Add the com.google.android.material:material dependency to app/build.gradle.kts (a specific, recent version), sync Gradle, and confirm the sync completes without errors. Add a short comment noting what "Sync Now" actually does, based on the Gradle vs npm comparison in this chapter.

Goal: Practice the dependency-declaration + sync workflow that every later chapter's new library will use.

โ†’ Solution

๐Ÿ’ก Slow Builds the First Time Are Normal

The very first Gradle sync and build on a new machine can take several minutes as it downloads dependencies and build tools โ€” subsequent builds are dramatically faster thanks to caching. If a first sync seems stuck, it's very likely still downloading, not actually frozen.

๐ŸŽฏ What's Next

Next chapter: Activities & Lifecycle โ€” the Activity class, lifecycle callbacks, savedInstanceState, and reading Logcat output.