I'm encountering an issue when building my Android project using gradlew with Java 17. The error message I'm getting is:
"Could not resolve androidx.navigation:navigation-safe-args-gradle-plugin - 'a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 13'"
However, when I build and run the application through Android Studio, everything works fine. This error also appears in my Git Actions workflow as part of the CI process.
I need Java version 17 for my project. Can anyone help me understand why this error occurs when using gradlew and how to resolve it?
Additionally, I'm curious about the exact command that Android Studio is running, as the project builds successfully with the GUI. Understanding that command might provide insights into the issue.
the full info :
MacBook-Pro:My-Android me$ ./gradlew
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'My-Android'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0.
Required by:
project :
> No matching variant of androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 13, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.1' but:
- Variant 'apiElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 13
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
- Variant 'runtimeElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 13
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
- Variant 'sourcesElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 13)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
I'm not sure if it will work for you or if you found another solution, but for me it was updating my CircleCI image in my code here
image: cimg/android:2024.01
. Docs found here https://circleci.com/developer/images/image/cimg/android