New Free Tool:iPhone Duo Foldable Simulator & Live PWA Readiness Audit.

Test your site live
Kerweb. Agence Capacitor
Back to Blog
Architecture
5 min read read

Gradle 9.x, AGP 8.5+ & Kotlin 2.x Migration Guide for Capacitor Android

Julien Kermarec
September 25, 2026

Modernizing Your Android Build Pipeline

With the release of Kotlin 2.0 (K2 compiler) and recent Android Studio versions, Android build pipelines have evolved significantly. Many Capacitor developers encounter Namespace not specified errors or Java 21 compatibility conflicts.

4-Step Upgrade Guide

1. Update the Gradle Wrapper

In android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https://services.gradle.org/distributions/gradle-8.9-all.zip

2. Configure Android Gradle Plugin (AGP)

In android/build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:8.5.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.20"
}

3. Set Java 17 / Java 21 Compatibility

In android/app/build.gradle:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
}

4. Clean and Sync Project

Run in your terminal:

cd android
./gradlew clean
Gradle 9
Kotlin 2
Java 21
Build Tools
Is your mobile application stuck or rejected on app stores?
Julien Kermarec (certified Ionic Developer Expert) and the Kerweb team intervene within 24-48h to resolve policy rejections, fix native manifests and secure your release.
Resolve Store Rejection