Releases: google/guava
33.3.1
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.3.1-jre</version>
<!-- or, for Android: -->
<version>33.3.1-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Added
j2objc-annotationsto the Gradle runtime classpath to stop producing an Android Gradle Plugin error. (a3b5188)
33.3.0
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.3.0-jre</version>
<!-- or, for Android: -->
<version>33.3.0-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
base: Removed@Betafrom theDurationoverload ofSuppliers.memoizeWithExpiration. (76fca99)cache: AddedCacheBuilderDurationoverloads toguava-android. (a5f9bca)collect: Removed@Betafrom theguava-androidCollectorAPIs. (c86c09d)collect: AddedImmutableMultimap.builderWithExpectedKeysandImmutableMultimap.Builder.expectedValuesPerKey. (c3d5b17)graph: ImprovedGraphs.hasCycleto avoid causingStackOverflowErrorfor long paths. (63734b9)net: Addedtext/markdowntoMediaType. (2466a09)net: DeprecatedHttpHeadersconstant forSec-Ch-UA-Form-Factorin favor ofSec-Ch-UA-Form-Factorsto follow the latest spec. (b310b7e)testing: Changed some test libraries to throwAssertionError(instead of the more specificAssertionFailedError) in some cases. (fdfbed1)
33.2.1
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
<!-- or, for Android: -->
<version>33.2.1-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
net: ChangedInetAddress-Stringconversion methods to preserve the IPv6 scope ID if present. The scope ID can be necessary for IPv6-capable devices with multiple network interfaces. However, preserving it can also lead to problems for callers that rely on the returned values not to include the scope ID:- Callers might compensate for the old behavior of the methods by appending the scope ID to a returned string themselves. If so, you can update your code to stop doing so at the same time as you upgrade Guava. Of, if your code might run against multiple versions of Guava, you can check whether Guava has included a scope ID before you add one yourself.
- Callers might pass the returned string to another system that does not understand scope IDs. If so, you can strip the scope ID off, whether by truncating the string form at a
%character (leaving behind any trailing]character in the case offorUriString) or by replacing the returnedInetAddresswith a new instance constructed by callingInetAddress.getByAddress(addr). java.net.InetAddressvalidates any provided scope ID against the interfaces available on the machine. As a result, methods inInetAddressesmay now fail if the scope ID fails validation.- Notable cases in which this may happen include:
- if the code runs in an Android app without networking permission
- if code passes
InetAddressinstances or strings across devices
- If this is not the behavior that you want, then you can strip off the scope ID from the input string before passing it to Guava, as discussed above. (3f61870)
- Notable cases in which this may happen include:
33.2.0
Android users: Please test recent Guava versions
If you know of Guava Android users who have not yet upgraded to at least release 33.0.0, please encourage them to upgrade, preferably to today's release, 33.2.0. These releases have begun adding Java 8+ APIs to guava-android. While we don't anticipate problems, we do anticipate that any unexpected problems could force a disruptive rollback. To minimize any disruption, we'd like to catch any such problems early.
Please let us know of any problems you encounter.
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.0-jre</version>
<!-- or, for Android: -->
<version>33.2.0-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Dropped testing for Android versions before Lollipop (API Level 21). Guava may stop working under older versions in the future, or it may have done so already.
- Fixed a GWT compilation breakage under Gradle. (858caf4)
collect: Made ourCollectorAPIs (e.g.,ImmutableList.toImmutableList()) available inguava-android. More Java 8 APIs will follow in future releases. (96fca0b)- As always, streams are available to Android code only when that code enables library desugaring or targets a new enough API Level (24 (Nougat) for many stream APIs). (But note that we test only with library desugaring, so we don't currently know if API Level 24 is high enough to use our
CollectorAPIs unless you have also enabled library desugaring.) Guava users who avoid theCollectorAPIs do not need to meet this requirement.
- As always, streams are available to Android code only when that code enables library desugaring or targets a new enough API Level (24 (Nougat) for many stream APIs). (But note that we test only with library desugaring, so we don't currently know if API Level 24 is high enough to use our
collect: Fixed a potentialNullPointerExceptioninImmutableMap.Builderon a rare code path. (70a9811)net: AddedHttpHeadersconstantsAd-Auction-Allowed,Permissions-Policy-Report-Only, andSec-GPC. (7dc01ed, 41d0d9a, 38c8017)
33.1.0
Request for Android users
If you know of Guava Android users who have not yet upgraded to at least the previous release 33.0.0, please encourage them to do so. Starting with that version, we are experimenting with including Java 8+ APIs in guava-android. Before we commit to adding such APIs, we want as much testing as we can get: If we later expose a set of Java 8+ APIs and then discover that they break users, we won't want to remove them, as the removal would break users, too.
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.1.0-jre</version>
<!-- or, for Android: -->
<version>33.1.0-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Updated our Error Prone dependency to 2.26.1, which includes a JPMS-ready jar of annotations. If you use the Error Prone annotations in a modular build of your own code, you may need to add a
requiresline for them. (d48c6df, c6e91c4) base: Added aDurationoverload forSuppliers.memoizeWithExpiration. (76e46ec)base: Deprecated the remaining two overloads ofThrowables.propagateIfPossible. They won't be deleted, but we recommend migrating off them. (cf86414)cache: Fixed a bug that could cause false "recursive load" reports during refresh. (0e1aebf)graph: Changed the return types oftransitiveClosure()andreachableNodes()toImmutable*types.reachableNodes()already returned an immutable object (even though that was not reflected in the declared return type);transitiveClosure()used to return a mutable object. The old signatures remain available, so this change does not break binary compatibility. (09e655f)graph: Changed the behavior of views returned by graph accessor methods that take a graph element as input: They now throwIllegalStateExceptionwhen that element is removed from the graph. (8dca776)hash: OptimizedChecksum-based hash functions for Java 9+. (afb35a5)testing: ExposedFakeTickerDurationmethods to Android users. (f346bbb)util.concurrent: Deprecated the constructors ofUncheckedExecutionExceptionandExecutionErrorthat don't accept a cause. We won't remove these constructors, but we recommend migrating off them, as users of those classes often assume that instances will contain a cause. (1bb3c43)util.concurrent: Improved the correctness of racy accesses for J2ObjC users. (d3232b7)
33.0.0
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.0.0-jre</version>
<!-- or, for Android: -->
<version>33.0.0-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- This version of
guava-androidcontains some package-private methods whose signature includes the Java 8CollectorAPI. This is a test to identify any problems before we expose those methods publicly to users. Please report any problems that you encounter. (73dbf7e) - Changed various classes to catch
Exceptioninstead ofRuntimeExceptioneven when onlyRuntimeExceptionis theoretically possible. This can help code that throws undeclared exceptions, as some bytecode rewriters (e.g., Robolectric) and languages (e.g., Kotlin) do. (c294c23, 747924e, b2baf48) - Added an
Automatic-Module-Nametofailureaccess, Guava's one strong runtime dependency. (280b5d2) reflect: Inguava-androidonly, removedInvokable.getAnnotatedReturnType()andParameter.getAnnotatedType(). These methods never worked in an Android VM, and to reflect that, they were born@Deprecated,@Beta, and@DoNotCall. They're now preventing us from rolling out some new Android compatibility testing. This is the only binary-incompatible change in this release, and it should have no effect in practice. Still, we bump the major version number to follow Semantic Versioning. (045cd84)util.concurrent: Changed our implementations to avoid eagerly initializing loggers during class loading. This can help performance, especially under Android. (4fe1df5)
32.1.3
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
<!-- or, for Android: -->
<version>32.1.3-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Changed Gradle Metadata to include dependency versions directly. This may address "Could not find
some-dependency" errors that some users have reported (which might be a result of users' excludingguava-parent). (c6d35cf) collect: ChangedMultisets.unmodifiableMultiset(set).removeIf(predicate)to throw an exception always, even if nothing matchespredicate. (61dbccf)graph: Fixed the behavior ofGraph/ValueGraphviews for a node when that node is removed from the graph. (9507996)io: FixedFiles.createTempDirandFileBackedOutputStreamunder Windows services, a rare use case. (The fix actually covers only Java 9+ because Java 8 would require an additional approach. Let us know if you need support under Java 8.) (f87f68c)net: MadeMediaType.parseallow and skip over whitespace around the/and=separator tokens in addition to the;separator, for which it was already being allowed. (2786f83)util.concurrent: TweakedFutures.getCheckedconstructor-selection behavior: The method continues to prefer to call constructors with aStringparameter, but now it breaks ties based on whether the constructor has aThrowableparameter. Beyond that, the choice of constructor remains undefined. (For this and other reasons, we discourage the use ofgetChecked.) (59cfb22)
32.1.2
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
<!-- or, for Android: -->
<version>32.1.2-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Removed the section of our Gradle metadata that caused Gradle to report conflicts with
listenablefuture. (9ed0fa6) - Changed our Maven project to avoid affecting which version of Mockito our Gradle users see. (71a16d5)
collect: Under J2CL, exposedImmutableListandImmutableSetmethodscopyOfandoffor JavaScript usage. (b41968f)net: OptimizedInternetDomainNameconstruction. (3a1d18f, eaa62eb)
32.1.1
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.1-jre</version>
<!-- or, for Android: -->
<version>32.1.1-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Fixed our broken Gradle metadata from 32.1.0. Sorry again for the trouble. If you use Gradle, please still read the release notes from that version: You may still see errors from the new checking that the metadata enables, and the release notes discuss how to fix those errors.
32.1.0
Warning: Our Gradle-metadata version numbers are broken. Read these notes, but upgrade straight to 32.1.2.
We made a mistake in our release script, so the new Gradle metadata (discussed below) has broken version numbers in 32.1.0. Sorry for the trouble and for the need for another quick patch release. We recommend upgrading straight to release 32.1.2, especially if you use Gradle or if you publish a library whose users might use Gradle. Still, read the release notes below if you use Gradle, since the fixed Gradle metadata in 32.1.2 may still require action on your part.
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.0-jre</version>
<!-- or, for Android: -->
<version>32.1.0-android</version>
</dependency>Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
Gradle Module Metadata
Warning: We made a mistake in our release script, so this is broken in 32.1.0. We recommend upgrading straight to release 32.1.2, especially if you use Gradle or if you publish a library whose users might use Gradle. Still, read the release notes below if you use Gradle, since the fixed Gradle metadata in 32.1.2 may still require action on your part.
The Gradle team has contributed a metadata file for Guava. If you use Gradle 6 or higher, you will see better handling of two kinds of dependency conflicts, plus another small feature related to our dependencies. As a result of this change, you may see errors, which you can resolve as documented below. If you encounter a problem that isn't documented below, or if the documentation is unclear, please let us know.
If you use Gradle 6 (not 5, not 7+)
You may see an error like this one:
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.google.guava:guava:30.1-jre.
Required by:
project : > com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:2.8.0 > gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:2.8.0
> The consumer was configured to find a runtime of a library compatible with Java 15, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of com.google.guava:guava:32.1.1-jre:
- androidRuntimeElements
- jreRuntimeElements
All of them match the consumer attributes:
- Variant 'androidRuntimeElements' capabilities com.google.collections:google-collections:32.1.1-jre and com.google.guava:guava:32.1.1-jre and com.google.guava:listenablefuture:1.0 declares a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally:
If you do, you'll need to add something like this to a place where you configure the Java plugins:
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}If you see an error about a duplicate ListenableFuture class
For example:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-32.1.1-android (com.google.guava:guava:32.1.1-android) and jetified-listenablefuture-1.0 (com.google.guava:listenablefuture:1.0)
This appears to be a Gradle bug.
@mathisdt has provided a workaround:
dependencies {
# dependency definitions here ...
modules {
module("com.google.guava:listenablefuture") {
replacedBy("com.google.guava:guava", "listenablefuture is part of guava")
}
}
}
Selecting the appropriate flavor
When Gradle automatically selects the newest version of Guava in your dependency graph, it will now also select the appropriate flavor (-android or -jre) based on whether you project targets Android or not. For example, if you depend on 32.1.0-android and 30.0-jre, Gradle will select 32.1.0-jre. This is the version most likely to be compatible with all your dependencies.
In the unusual event that you need to override Gradle's choice of flavor, you can do so as follows:
dependencies.constraints {
implementation("com.google.guava:guava") {
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment, TargetJvmEnvironment.ANDROID))
}
}
}
// If the above leads to a conflict error because there are additional transitive dependencies to Guava, then use:
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:guava") {
select(candidates.find { it.variantName.contains("android") })
}
}Reporting dependencies that overlap with Guava
If your dependency graph contains the very old google-collections or the hacky listenablefuture, Gradle will now report that those libraries contain duplicates of Guava classes. When this happens, you'll need to tell Gradle to select Guava:
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
// and/or
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:listenablefuture") {
select("com.google.guava:guava:0")
}
}If that doesn't work, please let us know. And let us know whether our replacedBy workaround or these other workarounds work instead.
Omitting annotations at runtime
One dependency of Guava that is not needed at runtime (j2objc-annotations) is now omitted from the runtime classpath. (We may omit others in the future. See #6606.)
Other changes
collect: Tweaked more nullness annotations. (501a016, 5c23590)hash: Enhancedcrc32c()to use Java's hardware-accelerated implementation where available. (65c7f10)util.concurrent: AddedDuration-baseddefaultmethods toListeningExecutorService. (e7714b0)- Began updating Javadoc to focus less on APIs that have been superseded by additions to the JDK. We're also looking to add more documentation that directs users to JDK equivalents for our APIs. Further PRs welcome! (c9efc47, 01dcc2e)
- Fixed some problems with using Guava from a Java Agent. (But we don't test that configuration, and we don't know how well we'll be able to keep it working.) (e42d4e8, de62703)
- Fixed
BootstrapMethodErrorwhen usingCacheBuilderfrom a custom system class loader. (As with the previous item, we're not sure how well we'll be able to keep this use case working.) (a667c38) - Suppressed a harmless
unusable-by-jswarning seen by users ofguava-gwt.