Stay organized with collections Save and categorize content based on your preferences.
Google Play services SDKs sometimes include, or depend upon, open source libraries. To comply with the license requirements of open source libraries, you as a developer are responsible for appropriately displaying the notices for the open source libraries that your app uses.
Google Play services includes a set of tools designed to give developers an easier way to express the open source software (OSS) notices of libraries used in their apps. The oss-licenses-plugin
and the Google Play services oss-licenses SDK collect license terms from included libraries, as declared in their POM files, and create an activity that can be used to display these terms. Learn more about how the tool finds and packages license information.
In your pluginManagement
of your project settings, do the following:
oss-licenses
plugin in the PluginManagement
.The following code snippet shows these steps:
Kotlin DSLsettings.gradle.kts
pluginManagement { repositories { ... google() } resolutionStrategy { eachPlugin { if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { useModule("com.google.android.gms:oss-licenses-plugin:0.10.6") } } } }Groovy DSL
build.gradle
pluginManagement { repositories { ... google() } resolutionStrategy { eachPlugin { if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { useModule("com.google.android.gms:oss-licenses-plugin:0.10.6") } } } }
In your app-level build file, apply the plugin by adding the following line under the existing declaration of the com.android.application
plugin at the top of the file:
app/build.gradle.kts
plugins { id("com.android.application") id("com.google.android.gms.oss-licenses-plugin") }Groovy DSL
app/build.gradle
plugins { id 'com.android.application' id 'com.google.android.gms.oss-licenses-plugin' }
You can view the code for this plugin on GitHub.
Add theplay-services-oss-licenses
library to your app
In the dependencies
section of your app-level build file, add a dependency on the play-services-oss-licenses
library:
build.gradle.kts
implementation("com.google.android.gms:play-services-oss-licenses:17.2.2")Groovy DSL
build.gradle
implementation 'com.google.android.gms:play-services-oss-licenses:17.2.2'Display license information
When your app builds, the Gradle plugin processes the licenses and adds them to your app's resources. To easily display the license, you can launch an activity that's provided by the play-services-oss-licenses
library at an appropriate point in your app, as shown in the following code snippet:
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity ... // When the user selects an option to see the licenses: startActivity(Intent(this, OssLicensesMenuActivity::class.java))Java
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity; ... // When the user selects an option to see the licenses: startActivity(new Intent(this, OssLicensesMenuActivity.class));
When the activity is launched, it displays a list of open source libraries that are compiled into your app, including libraries used by the app, as shown in figure 1. Users can tap on the name of a library to view additional license information for that library.
Figure 1. The licenses menu activity shows a selectable list of open source libraries that an app uses.
Set the activity titleBy default, the displayed activity has the title "Open source licenses". You can customize the title of the activity by calling setActivityTitle()
, as shown in the following code snippet:
OssLicensesMenuActivity.setActivityTitle(getString(R.string.custom_license_title))Java
OssLicensesMenuActivity.setActivityTitle(getString(R.string.custom_license_title));Apply a theme to the activity
You can apply a theme to the activity to match the theme used in your app's other activities. To do so, include the open source license activity in an <activity>
element within your app's manifest file, as shown in the following code snippet:
<application android:theme="@style/AppTheme" ...> <activity android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity" android:theme="@style/AppTheme" /> <activity android:name="com.google.android.gms.oss.licenses.OssLicensesActivity" android:theme="@style/AppTheme" /> </application>How the list of licenses is determined
At compile time, the Gradle plugin scans the POM dependencies of your app's project. When a Maven POM exists for a direct dependency of the app, the plugin processes each <licenses>
element and embeds the link and title of each license in an Android asset that's included with your app.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["Google Play services uses open source libraries, requiring developers to display licenses."],["A Gradle plugin helps by gathering license information and creating an activity to display them."],["Developers need to add the plugin, the library dependency, and launch the provided activity in their app."],["The license activity's title and theme can be customized."],["The plugin scans POM dependencies to compile the license list, including those used by Google Play services itself."]]],["Developers must display notices for open-source libraries used in their apps. Google Play services provides a Gradle plugin to streamline this. To use it, include the Google Maven repository and add the `oss-licenses` plugin in the root-level build file. Apply the plugin in the app-level build file and add the `oss-licenses` library as a dependency. The plugin then processes licenses from POM files and creates an activity via `OssLicensesMenuActivity` to display them. Developers can customize the activity's title and theme. The plugin scans direct and transitive dependencies, including those of Google Play services.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4