Ionic Capacitor Run error

Hi, i have a IONIC CAPACITOR project that build correctly on my JetBrains Rider ide. When i launch the command
IONIC CAPACITOR COPY and then i open Android Studio and run the project, it run fine.
But when, from Rider, i launch IONIC CAPACITOR ANDROID RUN and select my device i have this error:

Running Gradle build - failed!
[capacitor] [error]
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]
[capacitor]         * What went wrong:
[capacitor]         A problem occurred configuring root project 'android'.
[capacitor]         > Could not resolve all files for configuration ':classpath'.
[capacitor]         > Could not resolve com.android.tools.build:gradle:7.4.1.
[capacitor]         Required by:
[capacitor]         project :
[capacitor]         > No matching variant of com.android.tools.build:gradle:7.4.1 was found. The consumer was configured to find a runtime of a library compatible with Java 8, pack
aged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
[capacitor]         - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.1 declares a library, packaged as a jar, and its dependencies declared externally:
[capacitor]         - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Ja
va 8
[capacitor]         - Other compatible attribute:
[capacitor]         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
[capacitor]         - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.1 declares a runtime of a component, and its dependencies declared externally:
[capacitor]         - Incompatible because this component declares documentation and the consumer needed a library
[capacitor]         - Other compatible attributes:
[capacitor]         - Doesn't say anything about its target Java version (required compatibility with Java 8)
[capacitor]         - Doesn't say anything about its elements (required them packaged as a jar)
[capacitor]         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
[capacitor]         - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.1 declares a runtime of a library, packaged as a jar, and its dependencies declared ex
ternally:
[capacitor]         - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
[capacitor]         - Other compatible attribute:
[capacitor]         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
[capacitor]         - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.1 declares a runtime of a component, and its dependencies declared externally:
[capacitor]         - Incompatible because this component declares documentation and the consumer needed a library
[capacitor]         - Other compatible attributes:
[capacitor]         - Doesn't say anything about its target Java version (required compatibility with Java 8)
[capacitor]         - Doesn't say anything about its elements (required them packaged as a jar)
[capacitor]         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
[capacitor]
[capacitor]         * Try:
[capacitor]         > Run with --stacktrace option to get the stack trace.
[capacitor]         > Run with --info or --debug option to get more log output.
[capacitor]         > Run with --scan to get full insights.
[capacitor]
[capacitor]         * Get more help at https://help.gradle.org
[capacitor]
[capacitor]         BUILD FAILED in 1s
[capacitor]
[ERROR] An error occurred while running subprocess capacitor.

I need to run from Rider to have the capabilities of live debug to see the modified code

looks like it’s trying to use java 8 but gradle 7 requires java 11
but not sure how you can configure your app to use java 11 in that IDE

I’m using Java 11 on Android Studio Config like this:

The strange is that if i launch the project direct inside Android Studio it works

It’s not strange, Android Studio is configured to use java 11 as you have shown in the screenshot, so it works there, but the other IDE you use is not respecting that configuration and using java 8.

Make sure you have the JAVA_HOME variable set and pointing to a java 11 installation.

1 Like

1
My JAVA_HOME point at my JRE and this is the latest version available.
JAVA 11 maybe is about JDK ?
So i imagine i can’t point my JAVA_HOME to JDK

you can point JAVA_HOME to the JDK

EDIT

It works!

Thank you so much!

I just started ionic for Vue which generates Android via capacitor and it will automatically start Android Studio with an Android app. i just had Android Studio use JDK 18 that I had installed. My Java_Home uses a different version of Java so by default I was on the wrong version. For me I do Java, Python on the same machine and I end up using so many versions of Java. On projects with clients I often switch Java versions depending the apps on the many tasks which is very annoying but a way of life with things that do Java.