Build fails with ionic cap run android -l --external

After updating to latest @ionic/cli version I started receiving this error after I try to do this command : ionic cap run android -l --external

FAILURE: Build failed with an exception.
[capacitor] * Where:
[capacitor] Build file ‘E:\laragon\www\ProjekatA\frontend\android\app\build.gradle’ line: 1
[capacitor] * What went wrong:
[capacitor] A problem occurred evaluating project ‘:app’.
[capacitor] > Failed to apply plugin ‘’.
[capacitor] > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
[capacitor] You can try some of the following options:
[capacitor] - changing the IDE settings.
[capacitor] - changing the JAVA_HOME environment variable.
[capacitor] - changing in

When I run command ,everything works fine, app gets served but after this line error is triggered:

capacitor.cmd run android --no-sync --target Pixel_3_API_30

Also this is line executed before error presents itself in terminal :

E:\laragon\www\ProjekatA\frontend\android>“C:\Program Files\Java\jre1.8.0_291/bin/java.exe” “-Xmx64m” “-Xms64m” “-Dorg.gradle.appname=gradlew” -classpath “E:\laragon\www\ProjekatA\frontend\android\gradle\wrapper\gradle-wrapper.jar” org.gradle.wrapper.GradleWrapperMain “assembleDebug”

I change gradle JDK to this :

But the error is still present.

Also this is what I have installed on system :

Maybe I need to upgrade this? How and to which version if that is the case.

Thanks in advance!

I uninstalled every Java version I had, restarted computed and installed JDK 11.

After this there were no problems.