# Install Git, JDK 17, Android Studio And The SDK

> Set up Git, JDK 17 and the Android tooling you need to clone, open and build the course's Kotlin Multiplatform app.

- URL: https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/00-setup-app-running/lesson-01-install-android-studio-sdk
- Course: [Mobile Action Pro](https://dantech.academy/en/courses/kotlin-accelerator.md)
- Module: Setup App Running
- Duration: 10 min
- Difficulty: beginner
- Access: Free, full lesson
- Tiếng Việt: https://dantech.academy/courses/kotlin-accelerator/engineer-builder/00-setup-app-running/lesson-01-install-android-studio-sdk.md

## Objectives

- Install Git and set your commit identity with user.name and user.email
- Install JDK 17 and understand why the Gradle toolchain needs exactly this version
- Install a stable Android Studio, check the SDK components and get an emulator or a real phone ready

---

## Lesson Goal

By the end of this lesson your machine has the three things it needs to clone, open and build the course's Kotlin Multiplatform (KMP) project:

- Git to work with the repository,
- JDK 17 so Gradle can compile the code,
- Android Studio with the Android SDK to open, build and run the Android app.

The iOS side also needs macOS and Xcode, and it is optional. On Windows and Linux you can still take the whole course on Android.

## Before You Install Anything

When I set up a new machine, I don't clone the project right away. I check the toolchain first, because most "the project won't build" errors in the first week are really environment errors. A few extra minutes now save you hours of debugging later.

## Part 1: Install Git

Git is a tool that runs on your machine. You use it to clone repos, see changes and commit. GitHub and GitLab are services that host repositories. Git is what lets your machine work with them.

Official page: [Git official install page](https://git-scm.com/install/).

### Step 1: Download Git From The Official Page

| OS            | Recommended install                                                                                        |
| ------------- | ---------------------------------------------------------------------------------------------------------- |
| macOS         | Use the macOS option on the official page, or Homebrew with `brew install git` if you already use Homebrew |
| Windows       | Pick Windows on the official page and keep Git Bash enabled during the install                             |
| Ubuntu/Debian | Run `sudo apt update && sudo apt install git`                                                              |
| Fedora        | Run `sudo dnf install git`                                                                                 |

### Step 2: Open A New Terminal

After the install, close the old terminal and open a new one. The old terminal hasn't picked up the new PATH. Run:

```bash
git --version
```

The terminal should print a Git version. If it says `command not found` or `'git' is not recognized`, either Git didn't finish installing or the terminal hasn't picked up the PATH. Restart the machine and try again.

### Step 3: Configure Your Git Identity

You only need to do this once after installing Git:

```bash
git config --global user.name "Your Name"
git config --global user.email "[EMAIL_ADDRESS]"
```

`user.name` and `user.email` are the author details recorded on every commit. This command does not log you in to GitHub.

Check it:

```bash
git config --global user.name
git config --global user.email
```

## Part 2: Install JDK 17

The project uses a Gradle toolchain: every KMP module declares `jvmToolchain(17)` in the `KmpLibraryConventionPlugin` convention plugin (in the `build-logic/` folder). Gradle looks for a JDK 17 already installed on your machine to compile with. The repo doesn't configure automatic JDK downloads, so if your machine has no JDK 17, the build stops with:

```text
Cannot find a Java installation on your machine ... matching: {languageVersion=17, ...}
Toolchain download repositories have not been configured.
```

You still get this error if you already have JDK 21. The toolchain needs exactly version 17. The JDK bundled with Android Studio (the `jbr` folder) won't do either, because recent Android Studio releases ship JDK 21.

Install a JDK 17, for example Eclipse Temurin 17:

| OS            | How to install                                                                                                          |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| macOS         | `brew install --cask temurin@17`, or download the `.pkg` from [Adoptium](https://adoptium.net/temurin/releases/?version=17) |
| Windows       | Download the `.msi` from [Adoptium](https://adoptium.net/temurin/releases/?version=17) and install with the defaults    |
| Ubuntu/Debian | `sudo apt install openjdk-17-jdk`                                                                                       |
| Other Linux   | Install your distro's OpenJDK 17 package, or Temurin 17 from the Adoptium site                                          |

These installs put the JDK in the operating system's standard location, where Gradle finds it on its own. More on this: [Gradle toolchains](https://docs.gradle.org/current/userguide/toolchains.html).

Open a new terminal and check:

```bash
java -version
```

If you have several JDKs, `java -version` may print something other than 17. That's fine as long as JDK 17 is installed. To keep `./gradlew` commands stable, point `JAVA_HOME` at JDK 17. On macOS:

```bash
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 17)' >> ~/.zshrc
```

## Part 3: Install Android Studio And The Android SDK

Android Studio is Google's official IDE for Android. It includes the Android SDK, the emulator, device tools, Gradle integration and the code editor. It also opens and edits KMP code (`commonMain`, `androidMain`, `iosMain`).

- [Download Android Studio](https://developer.android.com/studio)
- [Install Android Studio guide](https://developer.android.com/studio/install)

Use the latest stable release. The repo uses Android Gradle Plugin 9, so an Android Studio that is too old won't sync.

### Step 1: Download The Stable Installer

Get the installer from the [Android Studio download](https://developer.android.com/studio) page, not from an unofficial site. If the page shows a preview or canary build, skip it. Install with your operating system's default steps.

### Step 2: Let The Setup Wizard Install The SDK

The first time you open Android Studio, choose the standard setup so the wizard installs the standard SDK components:

- Android SDK Platform
- Android SDK Build-Tools
- Android SDK Platform-Tools
- Android SDK Command-line Tools
- Android Emulator, if you use an emulator

### Step 3: Check The SDK Manager

1. Go to `Settings` (macOS: `Preferences`).
2. Open `Languages & Frameworks > Android SDK`.
3. Confirm an Android SDK location is set.
4. `SDK Platforms` tab: install a recent stable Android platform if none is there.
5. `SDK Tools` tab: install Build-Tools, Platform-Tools, Command-line Tools, and the Emulator if you need it.

Once you have accepted the licenses, Gradle downloads the exact SDK platform the project needs during the first build.

### Step 4: Get Somewhere To Run The App

You need at least one place to run the Android app:

- Emulator: open `Device Manager` in Android Studio and create a virtual device. See [Create and manage virtual devices](https://developer.android.com/studio/run/managing-avds).
- A real Android phone: turn on `Developer options`, turn on `USB debugging`, plug in the cable and accept the debugging prompt on the phone. See [Run apps on a hardware device](https://developer.android.com/studio/run/device). The app needs Android 8.0 (API 26) or newer.

With a real phone, `adb devices` must list your device with the state `device`.

## Check Everything In The Terminal

```bash
git --version
git config --global user.email
java -version
adb version
```

If `adb` isn't found, check that Platform-Tools is installed in the SDK Manager. Android Studio installs `adb` into the Android SDK's `platform-tools` folder but doesn't add that folder to PATH for you:

| OS      | Add `platform-tools` to PATH                                                                                                      |
| ------- | --------------------------------------------------------------------------------------------------------------------------------- |
| macOS   | `echo 'export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools"' >> ~/.zshrc`                                                 |
| Linux   | `echo 'export PATH="$PATH:$HOME/Android/Sdk/platform-tools"' >> ~/.bashrc`                                                        |
| Windows | Open `Edit environment variables for your account`, choose `Path` > `Edit` > `New`, paste `%LOCALAPPDATA%\Android\Sdk\platform-tools` |

These are the default SDK paths. If the SDK Manager shows a different path, use that one, then open a new terminal and run `adb version` again.

On Windows, open Git Bash once. It gives you a more reliable shell for the course commands.

You don't need to run `./gradlew` yet, because you haven't cloned the repo.

## Troubleshooting Table

![Troubleshooting infographic for Git, Android Studio and Android SDK setup: check git, adb, the SDK, the emulator, licenses and the first sync.](https://eaflqomlkbpdyzkiieby.supabase.co/storage/v1/object/public/content-media/courses/kotlin-accelerator/engineer-builder/00-setup-app-running/lesson-01-setup-troubleshooting-guide-en.webp)

| Error                                                     | Check first                                              |
| --------------------------------------------------------- | -------------------------------------------------------- |
| `Cannot find a Java installation ... languageVersion=17`  | Install JDK 17 as in Part 2, then open a new terminal or IDE |
| `java` is not on PATH                                     | Install JDK 17 and set `JAVA_HOME`                       |
| `adb` is not on PATH                                      | Add `platform-tools` to PATH                             |

## Checkpoint

Save the output of these commands so you can compare when a build fails:

```bash
git --version
git config --global user.email
java -version
adb version
```

---

- Next lesson: [Clone The Repo And Open The KMP Project For The First Time](https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/00-setup-app-running/lesson-02-clone-repo-open-project.md)
