androidionic-frameworkcapacitorionic-cli

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]
[capacitor]         * Where:
[capacitor]         Build file 'E:\laragon\www\ProjekatA\frontend\android\app\build.gradle' line: 1
[capacitor]
[capacitor]         * What went wrong:
[capacitor]         A problem occurred evaluating project ':app'.
[capacitor]         > Failed to apply plugin 'com.android.internal.application'.
[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 `org.gradle.java.home` in `gradle.properties`.

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

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 : Gradle JDK

But the error is still present.

Also this is what I have installed on system : Java JRE version

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

Thanks in advance!

Edit : When I build my app from Android Studio it works fine, it fails only when using ionic/cli.


Solution

  • I did as this guy suggested @@44_Chintan Vasoya, but I didn't delete android file because I already had some configuration set up.

    I just uninstalled Java then installed JDK 11 and it worked without a problem.

    Hope this helps somebody with same problem.

    SOLVED!