Android Fundamentals with Java

Setting Up Android Studio & a Project

18 min Lesson 2 of 12

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.
Java is bundled. Android Studio ships its own JDK (currently JDK 17). You do not need to install a separate JDK to build Android apps, though you can point the IDE at a system JDK via File → Project Structure → SDK Location → Gradle JDK if needed.

Installation

Download the installer from developer.android.com/studio and run it. The first-launch wizard will:

  1. Let you choose a UI theme (Darcula or Light).
  2. Download the Android SDK for the most recent stable platform (currently API 34 / Android 14). The SDK lands in ~/Android/Sdk on Linux/macOS or C:\Users\<you>\AppData\Local\Android\Sdk on Windows.
  3. Download a default Android Virtual Device (Pixel 8 Pro, API 34) and install the emulator.
  4. 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 (adb lives 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.

Be patient on first sync. Gradle downloads the Android Gradle Plugin, the Kotlin stdlib (even for Java projects, the build system uses Kotlin DSL by default in recent versions), and your declared dependencies. A fast internet connection is essential; after the first sync the files are cached in ~/.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 that MainActivity inflates.
  • 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:

package com.yourname.helloandroid; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }

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.

Emulator performance on Windows. If the emulator is very slow, verify that hardware virtualisation is enabled in your BIOS/UEFI, and that HAXM or WHPX is installed. On machines where hardware virt is unavailable (some corporate laptops with locked BIOS), use a physical Android device connected via USB instead — Android Studio detects it automatically once you enable USB Debugging in the device's Developer Options.

Running on a Physical Device

  1. On the Android device, go to Settings → About Phone and tap Build number seven times to unlock Developer Options.
  2. Go to Settings → Developer Options and enable USB Debugging.
  3. Connect the phone via USB. Accept the "Allow USB Debugging" prompt on the device.
  4. 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:

# In the project root directory: ./gradlew assembleDebug # build a debug APK ./gradlew installDebug # build + install on connected device/emulator ./gradlew test # run unit tests

The module-level app/build.gradle is where you will spend the most time. Understand its key sections:

plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' // present even in Java projects in recent templates } android { namespace 'com.yourname.helloandroid' compileSdk 34 defaultConfig { applicationId "com.yourname.helloandroid" minSdk 26 targetSdk 34 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false // set true + configure ProGuard for real releases proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } } dependencies { implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' }

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.