[Guava] Add escape hatches for jar includes. #1365
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are currently facing 2 issues related to the way Guava packages have been built.
Referencing Guava and Guava.ListenableFuture
After Guava was shipped, Google copied the
ListenableFuture
type to a separate package for users who did not want to bring in all of Guava. However, this type is also still in the Guava package. Referencing both of these packages causes both theguava.jar
andguava-listenablefuture.jar
packages to be added to the final application. This results in an error like:This PR adds an opt-out for the
guava-listenablefuture.jar
package that users can specify in their.csproj
to prevent it from being added to the final application. This should prevent the duplicate class error:This workaround was added in
Xamarin.Google.Guava.ListenableFuture
1.0.0.7
.We will be working on an automatic fix for this, but hopefully this should unblock people for now.
Multiple Guava Packages
Because
guava.jar
has traditionally been added as<EmbeddedReferenceJar>
, a copy of it is placed inside each Android bindings library that depends on it. If 2 bindings libraries reference different versions ofguava.jar
then there are duplicate incompatible versions which can cause as error.Going forward, we will bind
guava.jar
as<AndroidJavaLibrary>
. This mode does not include a copy ofguava.jar
in the bindings libraries. Instead, it is added from the transitive NuGet package to the final application so only the highest version of it will get added.However, this may cause issues in the interim until bindings libraries are updated. To facilitate this, an opt-out mechanism has been added that users can add to the
.csproj
to prevent the NuGetguava.jar
from being added to the application. This may prevent the duplicates until bindings can be updated:This workaround was added in
Xamarin.Google.Guava
31.1.0.1
.