Setting Up Android Studio & a Project
Setting Up Android Studio & a Project
Android Studio is the official IDE for Android development, built on IntelliJ IDEA and maintained by Google. It ships an integrated SDK Manager, an AVD Manager (Android Virtual Device — the emulator), a build system (Gradle), and a visual layout editor. Setting it up correctly the first time saves hours of debugging environment issues later.
System Requirements
Before downloading, confirm your machine meets the minimum requirements. As of Android Studio Hedgehog (2023.1) and later:
- OS: Windows 10/11 (64-bit), macOS 12 (Monterey) or later, Linux with glibc 2.31+.
- RAM: 8 GB minimum; 16 GB strongly recommended once the emulator is running alongside the IDE.
- Disk: 8 GB free (IDE + SDK) plus 4–8 GB per emulator system image.
- CPU: Intel/AMD x86_64 or Apple Silicon (M-series). Hardware virtualisation must be enabled for the emulator — on Windows this means Intel HAXM or Windows Hypervisor Platform (WHPX); on Linux it means KVM.
Installation
Download the installer from developer.android.com/studio and run it. The first-launch wizard will:
- Let you choose a UI theme (Darcula or Light).
- Download the Android SDK for the most recent stable platform (currently API 34 / Android 14). The SDK lands in
~/Android/Sdkon Linux/macOS orC:\Users\<you>\AppData\Local\Android\Sdkon Windows. - Download a default Android Virtual Device (Pixel 8 Pro, API 34) and install the emulator.
- Optionally install Intel HAXM (Windows/Linux Intel) for hardware-accelerated emulation.
After setup, open SDK Manager (Tools → SDK Manager) and ensure you have at least:
- Android SDK Platform (latest stable — API 34 or newer).
- Android SDK Build-Tools (matching version).
- Android Emulator.
- Android SDK Platform-Tools (
adblives here).
Creating Your First Android Project (Java)
From the Welcome screen click New Project. You will be shown a template gallery. For this tutorial always pick Empty Views Activity — it gives you one Activity, one layout XML, and minimal boilerplate. Avoid "Empty Activity" which may default to Compose; "Views Activity" confirms the traditional XML view system.
Fill in the New Project dialog:
- Name: e.g.
HelloAndroid. Use PascalCase. - Package name: a reverse-domain identifier, e.g.
com.yourname.helloandroid. This becomes your app's unique identifier on the Play Store and on the device. Keep it lowercase, no hyphens. - Save location: a path with no spaces or non-ASCII characters is safest.
- Language: Java — make sure to select Java here, not Kotlin.
- Minimum SDK: API 26 (Android 8.0 Oreo) is a reasonable floor — it covers ~95% of active devices while still giving you access to modern APIs.
Click Finish. Gradle will sync (download dependencies) for 1–3 minutes on the first run.
~/.gradle/caches and subsequent syncs are seconds.
What Android Studio Generated
After the sync you will see a project tree in the Android view (the drop-down at the top of the Project pane). Key items generated for you:
app/src/main/java/com/yourname/helloandroid/MainActivity.java— the entry-point Activity class.app/src/main/res/layout/activity_main.xml— the layout XML thatMainActivityinflates.app/src/main/AndroidManifest.xml— the app manifest (covered in Lesson 6).app/build.gradle— module-level Gradle build script (dependencies, compileSdk, minSdk, etc.).build.gradle(project-level) — plugin and repository declarations shared across modules.gradle/libs.versions.toml— version catalog (newer projects use this to centralise dependency versions).
Here is the generated MainActivity.java:
The class extends AppCompatActivity (from the AndroidX AppCompat library) rather than the bare Activity class. This gives you backwards-compatible toolbar support and other helpers. onCreate is the first lifecycle callback — we will study the full lifecycle in Lesson 4. setContentView(R.layout.activity_main) inflates your XML layout and makes it the visible content of the window.
Running on an Emulator
Open AVD Manager (Tools → Device Manager), select the pre-created Pixel device, and click the green triangle to boot it. Once the emulator is running, press the green Run button (or Shift+F10). Android Studio will compile your app, package it as an APK, install it on the emulator via adb, and launch your MainActivity. You should see "Hello World!" on screen.
Running on a Physical Device
- On the Android device, go to Settings → About Phone and tap Build number seven times to unlock Developer Options.
- Go to Settings → Developer Options and enable USB Debugging.
- Connect the phone via USB. Accept the "Allow USB Debugging" prompt on the device.
- Android Studio will list your device in the target drop-down. Select it and click Run.
Understanding the Build System (Gradle)
Android apps are built by Gradle, not by Android Studio itself — the IDE is just an orchestrator. This matters because you can build the same project from the command line:
The module-level app/build.gradle is where you will spend the most time. Understand its key sections:
Key terms: compileSdk is the API level you compile against (determines which APIs the compiler sees); minSdk is the lowest version your app will install on; targetSdk tells Android which version's behaviour model your app expects at runtime.
Summary
You now have Android Studio installed, an SDK configured, and a runnable "Hello World" app. The project wizard generated your first Activity, its layout XML, a manifest, and a Gradle build script. In the next lesson we will tour every folder and file in the project tree so you understand exactly where things belong before you start writing real code.