Setup: JDK, Android Studio, SDK & Emulator (AVD)
In this lesson, you’ll set up everything required to build Android apps in Java. We’ll install the JDK and Android Studio, configure the SDK, create an emulator (AVD), and (optionally) enable USB debugging on a real device.
Setup Overview
1. Install JDK
Java compiler/runtime for Android Studio & Gradle.
2. Android Studio
Official IDE + tools (SDK Manager, AVD Manager).
3. SDK Components
Platforms, Build-Tools, Platform-Tools (adb).
4. Emulator
Create & run a Virtual Device (Pixel API 34, etc.).
5. Device (Optional)
Enable USB Debugging + drivers.
Minimum Requirements
| Item | Recommended |
|---|---|
| RAM | 8 GB (16 GB for smooth emulator experience) |
| Disk Space | 10–20 GB free (SDKs, emulators consume space) |
| CPU | Enable Virtualization (Intel VT-x/AMD-V) in BIOS |
| OS | Windows 10/11, macOS, or a modern Linux distro |
1) Install JDK (Java Development Kit)
Android Studio includes its own runtime, but having a JDK is useful for Java tools and Gradle compatibility. Install a recent LTS (e.g., JDK 17). After installing, verify on the terminal/cmd:
// Windows (Command Prompt / PowerShell)
java -version
// macOS / Linux
java -version
You should see a version line (e.g., openjdk version "17.x").
Optional (Windows): set JAVA_HOME:
# Windows (PowerShell) – adjust your JDK path
setx JAVA_HOME "C:\Program Files\Java\jdk-17"
setx PATH "%PATH%;%JAVA_HOME%\bin"
2) Install Android Studio
- Download and install the latest Android Studio.
- Launch it and complete the first-time setup wizard.
- Choose the Standard installation (recommended).
adb), and essential components.3) Configure SDK Components
Open SDK Manager (toolbar icon or File → Settings → Appearance & Behavior → System Settings → Android SDK):
| Tab | What to select |
|---|---|
| SDK Platforms | Check the latest stable Android version (e.g., Android 14 (API 34)). You can add older versions (API 21+) if you need to test compatibility. |
| SDK Tools |
Ensure these are installed:
|
4) Create an Emulator (AVD)
- Open AVD Manager (toolbar phone icon).
- Click Create Virtual Device → choose a phone profile (e.g., Pixel 5).
- Select a system image (e.g., Android 14 (API 34)).
- Finish. Click the Play button to launch the emulator.
5) (Optional) Use a Real Device via USB
- On device: go to Settings → About phone → tap Build number 7 times to enable Developer options.
- In Developer options, turn on USB debugging.
- Connect via USB → accept the fingerprint prompt.
- On Windows, install OEM USB driver if device is not recognized.
Check device visibility:
adb devices
Development Flow (Big Picture)
Where are my SDK & Tools?
| Thing | Typical Location |
|---|---|
| SDK Path | Android Studio → Settings → Appearance & Behavior → System Settings → Android SDK (path shown at top) |
| Platform-Tools | <sdk>/platform-tools/ (contains adb) |
| Build-Tools | <sdk>/build-tools/<version> |
| AVD Images | Windows: C:\Users\<you>\.android\avd, macOS/Linux: ~/.android/avd |
Troubleshooting
Emulator extremely slow / won’t start
- Enable Virtualization in BIOS/UEFI (Intel VT-x / AMD-V).
- On Windows (Intel): install HAXM or use Hyper-V/WHPX (don’t mix both).
- On Windows (AMD): ensure WHPX is enabled; use x86_64 images.
- Close other hypervisors (VirtualBox/VMware) which can conflict.
“SDK not found / Build-tools missing”
- Open SDK Manager → install SDK Platform, Build-Tools, Platform-Tools.
- Check Android Studio Project Structure → SDK Location points to a valid SDK path.
“Gradle sync failed”
- Check internet connectivity; Gradle needs to download dependencies.
- If behind a proxy, set proxy in Appearance & Behavior → System Settings → HTTP Proxy.
- Try File → Invalidate Caches / Restart…
- Delete the project’s
.gradle/andbuild/folders and sync again (last resort).
Device not detected via USB
- Enable USB debugging and accept fingerprint prompt.
- Use a data-capable USB cable; try another port.
- Windows: install OEM USB driver (from your device manufacturer).
- Run
adb kill-serverthenadb start-server, thenadb devices.
“Application ID / Package name” confusion
- applicationId in Gradle uniquely identifies your app on Play Store/devices.
- Java package names (code) can differ from applicationId, but keeping them aligned is simpler.