-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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):
![image](https://private-user-images.githubusercontent.com/2906988/294789148-c280adbd-86b0-48e7-acbe-9051e7f9d898.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0MjExNjEsIm5iZiI6MTcyNDQyMDg2MSwicGF0aCI6Ii8yOTA2OTg4LzI5NDc4OTE0OC1jMjgwYWRiZC04NmIwLTQ4ZTctYWNiZS05MDUxZTdmOWQ4OTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjNUMTM0NzQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjcxM2IxMzE4NTU2ODU3MTMwMmRkNDA1MjdlZWEyNDZjMmJkZDZmMDZmNTUzMWUzMWZkNGJiYzM5ZDg4OWEwMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.rAKaYtcyAjDMAhnmFpWRFdPHnTnSLEV9mfubzOnAMzE)
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: