Files
Ontime/JDK_REQUIREMENTS.md
2026-03-11 15:29:37 +07:00

113 lines
2.9 KiB
Markdown

# JDK version for OnTime (User, Driver, Merchant)
## Required: **JDK 17** or **JDK 21**
The project uses:
- **Gradle 8.9** (gradle-wrapper)
- **Android Gradle Plugin 8.5.0** (User app; Driver/Merchant use similar)
- **App source/target:** Java 11 (Driver, Merchant); User follows Gradle default
Android Gradle Plugin 8.x needs **JDK 17** or newer. Use **JDK 17** or **JDK 21**.
---
## Install JDK
### macOS (Homebrew)
```bash
# JDK 17 (LTS)
brew install openjdk@17
# Or JDK 21
brew install openjdk@21
```
Then link and set `JAVA_HOME` (add to `~/.zshrc` or `~/.bash_profile`):
```bash
# For JDK 17
export JAVA_HOME="$(/usr/libexec/java_home -v 17 2>/dev/null || echo /opt/homebrew/opt/openjdk@17)"
export PATH="$JAVA_HOME/bin:$PATH"
```
### macOS (manual)
1. Download **JDK 17** or **21** from [Adoptium](https://adoptium.net/) or [Oracle](https://www.oracle.com/java/technologies/downloads/).
2. Install the `.pkg`.
3. Set `JAVA_HOME`, e.g. for Adoptium 17 on Apple Silicon:
```bash
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
```
### Windows
1. Download **JDK 17** or **21** from [Adoptium](https://adoptium.net/).
2. Run the installer and note the install path (e.g. `C:\Program Files\Eclipse Adoptium\jdk-17`).
3. Set environment variables:
- `JAVA_HOME` = that path
- Add `%JAVA_HOME%\bin` to `Path`.
### Linux (apt)
```bash
# JDK 17
sudo apt update
sudo apt install openjdk-17-jdk
# Or JDK 21
sudo apt install openjdk-21-jdk
```
Set `JAVA_HOME` if needed (e.g. in `~/.bashrc`):
```bash
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH="$JAVA_HOME/bin:$PATH"
```
---
## Check version
```bash
java -version
javac -version
```
You should see version **17** or **21**.
---
## Android SDK (required for building)
Gradle needs the Android SDK path. Either:
1. **Set `ANDROID_HOME`** (recommended):
```bash
export ANDROID_HOME=$HOME/Library/Android/sdk # macOS default
export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
```
2. **Or use `local.properties`** in each app folder (already created if you opened the project):
- `OnTime_User_live/local.properties`
- `OnTime_Driver_live/local.properties`
- `OnTime_Merchant_live/local.properties`
Each should contain:
```properties
sdk.dir=/Users/YOUR_USERNAME/Library/Android/sdk
```
Replace `YOUR_USERNAME` with your macOS username, or use the path where Android Studio installed the SDK (e.g. Windows: `C:\\Users\\You\\AppData\\Local\\Android\\Sdk`).
If the SDK is in a different location, edit `sdk.dir` in each `local.properties` or set `ANDROID_HOME` to that path.
---
Then build the apps:
```bash
./build-debug-apks.sh
```
Or open **OnTime_User_live**, **OnTime_Driver_live**, or **OnTime_Merchant_live** in Android Studio (it will use the JDK configured in **File → Settings → Build → Build Tools → Gradle**).