Skip to main content
Android Code Studio supports multiple JDK installations, allowing you to choose the appropriate Java version for your projects.

Supported JDK Versions

Android Code Studio includes support for:
  • JDK 11 - For projects using Android Gradle Plugin 7.x
  • JDK 17 (Recommended) - For projects using Android Gradle Plugin 8.x and newer
  • JDK 21 - For cutting-edge development
JDK 17 is the default and recommended version for most Android development.

JDK Installation Location

JDK installations are located in:
$PREFIX/lib/jvm/
Example paths:
  • /data/data/com.tom.rv2ide/files/usr/lib/jvm/java-17-openjdk
  • /data/data/com.tom.rv2ide/files/usr/lib/jvm/java-21-openjdk

Configuring JDK Version

Via Preferences UI

1

Open Preferences

Navigate to Settings > Build & Run > Gradle Options
2

Select JDK Version

Tap on JDK Version preferenceYou’ll see a list of installed JDK distributions with their version numbers.
3

Choose Version

Select your preferred JDK version from the listThe IDE will immediately update the JAVA_HOME environment variable.

Via Configuration File

The JDK preference is stored as:
ide.build.javaHome
string
Java Home Path - Full path to the selected JDK installationExample value: /data/data/com.tom.rv2ide/files/usr/lib/jvm/java-17-openjdk

JDK Detection

The IDE automatically detects installed JDK distributions using the following process:
1

Scan Installation Directory

Scans $PREFIX/lib/jvm/ for JDK installations
val optDir = File(Environment.PREFIX, "lib/jvm")
optDir.listFiles()
2

Validate Installation

Checks for valid bin/java executable:
  • File exists
  • Is a regular file (not a symlink)
  • Has executable permissions
3

Extract Version Information

Executes the Java binary to get version details:
java -XshowSettings:properties -version
Extracts:
  • java.version - Version string (e.g., “17.0.7”)
  • java.home - Actual installation path
4

Create Distribution Entry

Creates a JdkDistribution object:
data class JdkDistribution(
  val javaVersion: String,
  val javaHome: String
)

Default JDK Selection

On first launch, the IDE automatically selects a default JDK:
  1. Prefers JDK 17 if available (recommended for Android development)
  2. Falls back to first available JDK if JDK 17 is not installed
  3. Validates selection to ensure the installation is functional
var defaultDist = distributions.find {
  it.javaVersion.startsWith("17")
}

if (defaultDist == null) {
  defaultDist = distributions[0]
}

Environment Variables

The selected JDK sets the following environment variables:
# Core Java environment
export JAVA_HOME="/data/data/com.tom.rv2ide/files/usr/lib/jvm/java-17-openjdk"
export JAVA="$JAVA_HOME/bin/java"

# Library path for native libraries
export LD_LIBRARY_PATH="$PREFIX/lib:$JAVA_HOME/lib"

Installing Additional JDK Versions

Android Code Studio uses Termux packages for JDK installations.
1

Open Terminal

Open the IDE terminal (bottom panel)
2

Install via pkg

Use the pkg command to install JDK packages:
# Install JDK 17 (recommended)
pkg install openjdk-17

# Or install JDK 21
pkg install openjdk-21
Installation requires an internet connection and may take several minutes.
3

Restart IDE

Restart Android Code Studio to detect the new JDK installationThe new version will appear in the JDK selection list.

Switching JDK Versions

When to Switch

Switch JDK versions based on your project requirements:
Android Gradle PluginMinimum JDKRecommended JDK
AGP 7.0 - 7.4JDK 11JDK 11
AGP 8.0+JDK 17JDK 17
AGP 8.4+JDK 17JDK 21
Using an incompatible JDK version may cause build failures. Check your project’s build.gradle file for AGP version.

Switching Process

1

Check Current Version

Verify current JDK version in terminal:
java -version
echo $JAVA_HOME
2

Change in Preferences

Go to Settings > Build & Run > JDK VersionSelect the desired version from the list
3

Verify Change

The change takes effect immediately. Verify in terminal:
java -version
4

Clean and Rebuild

For existing projects, clean and rebuild:
./gradlew clean build

Troubleshooting

JDK Not Detected

If a JDK installation is not detected:
1

Verify Installation

Check that the JDK is installed:
ls -la $PREFIX/lib/jvm/
2

Check Java Binary

Ensure the java binary exists and is executable:
ls -la $PREFIX/lib/jvm/java-17-openjdk/bin/java
chmod +x $PREFIX/lib/jvm/java-17-openjdk/bin/java
3

Restart IDE

Close and reopen Android Code Studio to trigger JDK detection

Build Fails with JDK Error

If builds fail with JDK-related errors:
  1. Check AGP Compatibility
    // In build.gradle
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.0' // Check version
    }
    
  2. Verify JAVA_HOME
    echo $JAVA_HOME
    $JAVA_HOME/bin/java -version
    
  3. Clear Gradle Cache
    rm -rf ~/.gradle/caches/
    ./gradlew clean
    

Multiple JDK Versions Not Showing

If only one JDK appears despite multiple installations:
# List all JDK directories
ls -la $PREFIX/lib/jvm/

# Check for symbolic links (these are ignored)
file $PREFIX/lib/jvm/*

# Ensure each has a valid java binary
for jdk in $PREFIX/lib/jvm/*/; do
  echo "Checking $jdk"
  ls -l "${jdk}bin/java"
done
Symbolic links are intentionally ignored during JDK detection to avoid duplicate entries.

JDK Configuration Best Practices

Keep JDK 17 Installed - JDK 17 is the most compatible version for modern Android development and should always be available.
Match Project Requirements - Always use the JDK version required by your project’s Android Gradle Plugin version.
Update Regularly - Keep your JDK installations updated through pkg update && pkg upgrade.

Advanced Configuration

Custom JDK Installation

To use a custom JDK installation:
  1. Install JDK to $PREFIX/lib/jvm/custom-jdk/
  2. Ensure Structure:
    custom-jdk/
    ├── bin/
    │   └── java (executable)
    ├── lib/
    └── ...
    
  3. Set Permissions:
    chmod +x $PREFIX/lib/jvm/custom-jdk/bin/java
    
  4. Restart IDE to detect the new installation

Per-Project JDK (gradle.properties)

While the IDE sets a global JAVA_HOME, you can override it per-project:
# In gradle.properties
org.gradle.java.home=/data/data/com.tom.rv2ide/files/usr/lib/jvm/java-21-openjdk
This overrides the IDE’s JDK selection for Gradle builds only. Language servers will still use the IDE’s configured JDK.

Build docs developers (and LLMs) love