Android Studio and SDK

Android Studio and the Android SDK

Capacitor 8 243,123 requires Android Studio 234 Otter 2025.2.1 or later if you use the IDE, which npx cap open android launches. Android Studio bundles its own JDK, so IDE users install nothing else. The SDK packages, emulator and ANDROID_HOME are exactly those of Android Toolchain; Capacitor needs SDK Platform 36 for its compileSdk.

The JDK is the one trap. Android Toolchain installed JDK 17 for Cordova 129 , but Capacitor's Android library has compiled for Java 21 since Capacitor 7: node_modules/@capacitor/android/capacitor/build.gradle sets sourceCompatibility JavaVersion.VERSION_21, where the 6.2.2 release still says VERSION_17. On a headless machine, build once with each JDK to see the difference:

Building the Capacitor project with JDK 17, then JDK 21Shell
cd android
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./gradlew assembleDebug --no-daemon
JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 ./gradlew assembleDebug --no-daemon
Output
...
> Task :capacitor-android:compileDebugJavaWithJavac FAILED
...
Execution failed for task ':capacitor-android:compileDebugJavaWithJavac'.
> Java compilation initialization error
    error: invalid source release: 21
...
BUILD FAILED in 36s
...
BUILD SUCCESSFUL in 43s
93 actionable tasks: 55 executed, 38 up-to-date

On Ubuntu 225 , sudo apt-get install openjdk-21-jdk-headless installs JDK 21 beside JDK 17. Set JAVA_HOME per shell or per build script rather than switching the system default, so the other chapters keep the JDK 17 they were built with.