MS Code Ionic Plugin: run Android failure

I generated an ionic Angular menu for web and Android changed next to nothing (the name in ionic.config.json, and the title in index.html)

I use the ionic plugin in MS Code
Run | Android works great,
so does the comand
> ionic serve
I try the Ionic plugin
run android (and I pick pixel 5 API 29 (emulator) Android 10)
see error message starting at “What went wrong”
In the MS code terminal

> java -version
java version "24.0.1" 2025-04-15
Java(TM) SE Runtime Environment (build 24.0.1+9-30)
Java HotSpot(TM) 64-Bit Server VM (build 24.0.1+9-30, mixed mode, sharing)

I don’t know what to fix to set to a new JVM or change what I am targeting.
I got the following results:

   * What went wrong:
    A problem occurred configuring root project 'android'.
    > Could not resolve all artifacts for configuration 'classpath'.
    > Could not resolve com.android.tools.build:gradle:8.7.2.
    Required by:
    root project :
    > Dependency requires at least JVM runtime version 11. This build uses a Java 8 JVM.
    > Could not resolve com.google.gms:google-services:4.4.2.
    Required by:
    root project :
    > Dependency requires at least JVM runtime version 11. This build uses a Java 8 JVM.

    * Try:
    > Run this build using a Java 11 or newer JVM.
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at https://help.gradle.org.
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
    
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

Android Studio comes with its own built-in Java runtime and uses it by default. See my screenshot over here to see which JDK you are using for your project - Unable to get Capacitor to output web and mobile builds - #2 by twestrick

1 Like

They are running from the Ionic VS Code Ionic plugin, that’s the same as running from the terminal, in that case it doesn’t use Android Studio’s JDK but the global configured one (i.e. the one configured with JAVA_HOME), which by the java -version message, looks like it’s JDK 24.
As far as I know, gradle doesn’t support JDK 24, they should downgrade the JDK to a previous version.
While the message says “at least Java 11”, I would recommend using Java 21 since that’s the recommended for Capacitor 7.

If keeping Java 24 in JAVA_HOME is needed for some other tooling, the GRADLE_LOCAL_JAVA_HOME variable can be used instead.

1 Like