-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
x.y.z-jre version has -android.jar artifact with missing -jre classes #6904
Comments
This is the expected behavior. Although, I know that it is confusing, because the version string with the To select the JRE version in Android do what you have commented out:
It's not a "workaround", but a way to tell Gradle to select a different variant than your JVM environment's default. Since Ideally, there won't be two versions Because of the above, it gets confusing when you look at the resolution result of Gradle. In your example it says that it resolved to You can use
Here we have the clues With this comment, I only want to explain the situation. I don't want to say that things are perfect as they are. But I am not sure what a concrete next action would be. Things I see:
|
Sorry, @TWiStErRob, for the trouble with this, and thanks again, @jjohannes, for jumping in with an explanation. I still need to do more about this class of problem. My recent work has been mostly to add APIs like I think you're right that this is fundamentally the same as #6801, so I'll try to consolidate things back there. |
Description
I don't fully understand the problem, so I'm just going to provide a tiny repro here and some guess-work explanation.
Originally the problem came from an Android project with Paparazzi tests, but I managed to eliminate Paparazzi from the picture, only Android Unit Tests with simple dependencies remain.
com.android.tools.layoutlib:layoutlib-api
artifact has an enum calledcom.android.resources.ResourceType
, which in it's static class initializer callsSets.toImmutableEnumSet()
. So far nothing special, this works as expected.However as soon as there's a more complex dependency graph, more specifically: a dependency on Guava 32.1.1+
-jre
variant, the classpath becomes strange. An error can happen where the above mentionedtoImmutableEnumSet
doesn't exist on runtime classpath with the right visibility modifier.Guess-work
I think this is because of
As I see, without the experiment it would be a different error only, so my guess is that this comes down to metadata. Mentioning both of you, because I think you're the best make heads or tails of this.
Example
Repro:
gradlew test
Relevant code pieces
Expected Behavior
Test passes.
More specifically: when resolving to version
...-jre
, ONLY the-jre.jar
is on the classpath.Actual Behavior
More details
Project Synced in Android Studio shows the culprit (this blew my mind):
Here are a few version and their paths:
It seems from 33.0.0, the version and variant matches, but to trump this all off, when doing
gradlew :dependencies --configuration=debugUnitTestRuntimeClasspath
I get (irrelevant lines omitted):where there's no mention of
-android
!Packages
com.google.common.collect
Platforms
Android, Java 17
Checklist
The text was updated successfully, but these errors were encountered: