nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

[Bug]: Issue while running ./gradlew build

Open er-abhishek-luthra opened this issue 1 year ago • 5 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is there a StackOverflow question about this issue?

  • [X] I have searched StackOverflow

What happened?

Issue while running ./gradlew build

Could not determine the dependencies of null. Could not resolve all task dependencies for configuration ':app:classpath'. > Could not resolve project :build-logic:convention. Required by: project :app > No matching variant of project :build-logic:convention was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.2' but: - Variant 'apiElements' capability com.tandroosti.eua.buildlogic:convention:unspecified 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 11

Relevant logcat output

> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':app:classpath'.
      > Could not resolve project :build-logic:convention.
        Required by:
            project :app
         > No matching variant of project :build-logic:convention was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.2' but:
             - Variant 'apiElements' capability com.tandroosti.eua.buildlogic:convention:unspecified 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 11

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

er-abhishek-luthra avatar Aug 19 '23 18:08 er-abhishek-luthra

It looks like you might be trying to use JDK 11 to build Now in Android?

Building Now in Android requires JDK 17 or later.

alexvanyo avatar Aug 21 '23 17:08 alexvanyo

The logs you give us are the raw logs of the build. But, if you run this from Android Studio, it will show up this message:

Gradle JVM version incompatible.
This project is configured to use an older Gradle JVM that supports up to version 11 but the current AGP requires a Gradle JVM that supports version 17.

Change Gradle JDK...
See AGP Release Notes...

And the last two lines are links to configure the JDK.


That being said, we could override this behavior and force checking for the appropriate version (and maybe only if System.getProperty("idea.active") is not defined):

if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17).not()) {
    throw GradleException(
        """
        Now in Android requires JDK 17 but it is currently using JDK ${JavaVersion.current()}.
        Java Home: [${System.getProperty("java.home")}]
        """.trimIndent()
    )
}

WDYT?

SimonMarquis avatar Aug 22 '23 19:08 SimonMarquis