Android Studio Setup & First App
๐ฑ Android Studio Setup & First App
โฌ๏ธ 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
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.
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:
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 command | npm install | "Sync Now" (automatic on file changes) |
| Where deps come from | npm registry | Maven repositories (Google's, Maven Central) |
| Build/run command | npm run build | Run โถ 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:
- Open Device Manager (usually a phone-shaped icon in the toolbar or right-hand panel).
- 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.
- 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.
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.
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.
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.
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.