Running Gradle Build – Failed When i tried to run ionic capacitor run android -l –external


so before i just changed my device, my ionic project working just fine when i tried to run live reload. i think i have installed all the same version of jdk and node js as my old device.

and now, i’ve been getting this error when i tried to run ionic cap run android -l –external

[capacitor] × Running Gradle build - failed!
[capacitor] [error]
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]         * What went wrong:
[capacitor]         Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
[capacitor]         > Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
 [in thread "Daemon worker"]
[capacitor]         * Try:
[capacitor]         Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run wi
th --scan to get full insights.
[capacitor]         * Get more help at
[capacitor]         BUILD FAILED in 1s
[ERROR] An error occurred while running subprocess capacitor.

i’ve been looking for answers, and mostly they told me to change this line of code


but it just gave me another error. i tried to change it to some other versions. but still, it didnt work.

I expected my ionic app will be able to run livereload.


I resolved this problem by adding this line in my

org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/ --add-opens=jdk.compiler/ --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/ --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

Answered By – spardano

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published