Use Bill of Materials (BOM) with Cloud Client Libraries for Java

To make sure that your projects have compatible versions ofCloud Client Libraries, use the versions specified in the Google CloudLibraries Bill of Materials (BOM). The libraries in the BOM don't havedependency conflicts that would manifest asNoSuchMethodError orNoClassDefFoundError.

The BOM is necessary because Google publishes over two hundred open source Javalibraries that make it easier to use services in Google Cloud. TheGoogle Cloud libraries depend on several foundational libraries that canbe used for general purposes.

These recommendations apply to the components of the following libraries:

Updating your project to use the BOM

To make sure that your projects uses compatible versions of the librariesand their component artifacts, importcom.google.cloud:libraries-bom and usethe BOM to specify dependency versions. Be sure to remove any versions that youset previously.

If you encounter compatibility issues with protobuf-java 4.x, update your codebaseand dependencies to ensure compatibility, see release notes oflibraries-bom v26.50.0 andlibraries-bom v26.75.0for potential compatibility issues.

Maven

Import the BOM in thedependencyManagement section of yourpom.xml file.Include specific artifacts you depend on in thedependencies section, but don'tspecify the artifacts' versions in thedependencies section. The example belowdemonstrates how you would import the BOM and include thegoogle-cloud-storageartifact.

<dependencyManagement>  <dependencies>    <dependency>      <groupId>com.google.cloud</groupId>      <artifactId>libraries-bom</artifactId>      <version>26.75.0</version>      <type>pom</type>      <scope>import</scope>    </dependency>  </dependencies></dependencyManagement><dependencies>  <dependency>    <groupId>com.google.cloud</groupId>    <artifactId>google-cloud-storage</artifactId>  </dependency>  <dependency>    <groupId>com.google.cloud</groupId>    <artifactId>google-cloud-storage-control</artifactId>  </dependency></dependencies>

In this example, because the BOM manages library versions, theversion ofgoogle-cloud-storage is omitted.

Gradle

BOMs are supported by default in Gradle 5.x or later. Add aplatformdependency oncom.google.cloud:libraries-bom and remove the version from thedependency declarations in the artifact'sbuild.gradle file.

implementation platform('com.google.cloud:libraries-bom:26.75.0')implementation 'com.google.cloud:google-cloud-storage'

Theplatform andenforcedPlatform keywords supply dependency versionsdeclared in a BOM. TheenforcedPlatform keyword enforces the dependencyversions declared in the BOM and thus overrides what you specified.For more details of theplatform andenforcedPlatform keywords Gradle 5.x or higher, seeGradle: Importing Maven BOMs.

If you're using Gradle 4.6 or later, addenableFeaturePreview('IMPROVED_POM_SUPPORT') to yoursettings.gradle file.For details, seeGradle 4.6 Release Notes: BOM import.Versions of Gradle earlier than 4.6 don't support BOMs.

SBT

SBTdoesn't support BOMs. You can findrecommended versions of libraries from a particular BOM version on thedashboardand set the versions manually.

Bazel

Bazeldoesn't support BOMs.You can find recommended versions of libraries from a particular BOM versionon thedashboardand set the versions manually.

Guava Versions-jre or-android

Since the release of version 21.0.0, the Libraries BOM includes Guava's-jreversion (which supports Java 8+). The section below is not applicable for Java 8users.


Google's Guava release contains two versions of artifacts:"-jre" and "-android" versions.The one with "-jre" (such ascom.google.guava:guava:31.1-jre) isfor Java 8 and supports lambda functions and streams.The other version with the "-android" suffix (such ascom.google.guava:guava:31.1-android) is for Java 7 and Android development.

The Google Cloud Libraries BOM contains Guava with the "-android" versionto make sure that the BOM works in Java 7. However, this means the version ofGuava in the BOM doesn't have some methods that are intended for Java 8 lambdafunctions, such asImmutableList.toImmutableList().

If your project requires Java 8 or later and uses Guava classessuch ascom.google.common.collect.Streams, you should add a dependency on aJRE version of Guava.

In Maven:

<dependencyManagement><dependencies><dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>31.1-jre</version><!--"-jre"forJava8orhigher--></dependency></dependencies><dependencies><dependency><groupId>com.google.cloud</groupId><artifactId>libraries-bom</artifactId>...</dependencyManagement>

In Gradle:

dependencies{constraints{implementation'com.google.guava:guava:31.1-jre'// "-jre" for Java 8 or higher}implementationplatform('com.google.cloud:libraries-bom:26.12.0')...}

The previous sample doesn't work if you useenforcedPlatform becauseenforcedPlatform takes precedence overconstraints. If you want to useenforcedPlatform with the Guava version, you can configureResolutionStrategy.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.