Gradle.build troubleshoot


You’re hitting a Gradle/AGP mismatch that older Capacitor/Cordova plugins trigger. That specific error (“Cannot select root node ‘debugRuntimeClasspathCopy’…”) shows up when Gradle 8+ meets plugins that were written for Gradle 7.x. Fix = align versions (preferably upgrade everything; fallback is temporarily downgrading Gradle/AGP).

Here’s a clean, do-this-now path:

Option A — Upgrade (recommended)

  1. Verify Capacitor versions (all same major):
cd C:\Users\Heru Da Guru\projects\<your-app>
npm ls @capacitor/cli @capacitor/core @capacitor/android

Update if needed:

npm i -D @capacitor/cli@latest
npm i @capacitor/core@latest @capacitor/android@latest
  1. Update any Cordova plugins (these feed capacitor-cordova-android-plugins):
npm outdated
# then bump the cordova-* or @awesome-cordova-* plugins to latest
npm i <each-plugin>@latest
  1. Set Android Gradle Plugin (AGP) and Gradle wrapper to current, compatible pair:
  • Edit android/build.gradle (project level) to use AGP 8.5.x:
plugins {
    id 'com.android.application' version '8.5.2' apply false
    id 'com.android.library'    version '8.5.2' apply false
}
  • Edit android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
  1. Clean caches and resync:
rd /s /q .\android\.gradle
rd /s /q .\android\build
rd /s /q .\android\app\build
npx cap sync android
cd android
.\gradlew --no-daemon --refresh-dependencies clean
.\gradlew assembleDebug

If it builds, you’re done.


Option B — Quick fallback (if you must build now)

Lock to older, compatible toolchain that those plugins expect:

  • android/build.gradle (project):
plugins {
    id 'com.android.application' version '7.4.2' apply false
    id 'com.android.library'    version '7.4.2' apply false
}
  • android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip

Then:

cd android
.\gradlew clean
.\gradlew assembleDebug

If it still complains

Find the plugin creating that bad *RuntimeClasspathCopy config:

cd android
.\gradlew :capacitor-android:dependencies --configuration debugRuntimeClasspath --stacktrace
.\gradlew :capacitor-cordova-android-plugins:dependencies --configuration debugRuntimeClasspath --stacktrace

Whichever Cordova/Capacitor plugin shows up just before the error is the one to upgrade/remove.


Minimal checklist (copy/paste)

cd "C:\Users\Heru Da Guru\projects\<your-app>"
npm i -D @capacitor/cli@latest
npm i @capacitor/core@latest @capacitor/android@latest
npm i <each-cordova-plugin>@latest
npx cap sync android

# set AGP/Gradle as above, then:
cd android
.\gradlew --no-daemon clean
.\gradlew assembleDebug