Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Issue while running ./gradlew build #910

Open
3 tasks done
er-abhishek-luthra opened this issue Aug 19, 2023 · 5 comments · May be fixed by #1671
Open
3 tasks done

[Bug]: Issue while running ./gradlew build #910

er-abhishek-luthra opened this issue Aug 19, 2023 · 5 comments · May be fixed by #1671
Labels
bug Something isn't working

Comments

@er-abhishek-luthra
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • 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

  • I agree to follow this project's Code of Conduct
@er-abhishek-luthra er-abhishek-luthra added the bug Something isn't working label Aug 19, 2023
@alexvanyo
Copy link
Contributor

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.

@SimonMarquis
Copy link
Contributor

SimonMarquis commented Aug 22, 2023

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?

@dturner
Copy link
Collaborator

dturner commented Oct 4, 2024

Agree with your suggested fix @SimonMarquis. Only thing I would add is that the message should also provide a solution (e.g., #1137 (comment)).

Feel free to submit a PR.

@SimonMarquis
Copy link
Contributor

I feel like the fix should not be to manually edit config files, but instead to use the Android Studio UI (File | Settings | Build, Execution, Deployment | Build Tools | Gradle) that will make sure the proper JDK is selected and configured in the right file:

https://developer.android.com/build/jdks and more precisely this https://developer.android.com/build/jdks#jdk-config-in-studio

image

@dturner
Copy link
Collaborator

dturner commented Oct 4, 2024

Sounds good to me. Just use that link in the error description.

SimonMarquis added a commit to SimonMarquis/nowinandroid that referenced this issue Oct 19, 2024
And abort current build with a message containing current Java version and a link to the official docs on how to setup the correct Java version.

Fixes android#910
@SimonMarquis SimonMarquis linked a pull request Oct 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants