Including Open Source Notices

Its up to every developer to appropriately display the notices to comply with the license requirements of open source libraries. Google Play services sometimes includes, or depends upon, open source libraries.

As of version 11.2.0, Google Play services includes a set of tools designed to give developers a easier way to express the open source software notices of libraries used in their apps. It includes a Gradle plugin that collects license terms from included libraries as declared in their POM files, and an Activity that can be used to display these terms.

Add the Gradle plugin

In your root-level build.gradle make sure you are using the Google maven repository and add the oss-licenses plugin to your dependencies:

buildscript {
  repositories {
    //...
    maven { url "https://maven.google.com" } // or google() for Gradle 4+
  }
  dependencies {
    //...
    // Add this line:
    classpath 'com.google.gms:oss-licenses:0.9.0'
   }

In your app-level build.gradle, apply the plugin by adding the following line under the existing apply plugin: 'com.android.application' at the top of the file:

apply plugin: 'com.google.gms.oss.licenses.plugin'

In the dependencies section add a dependency on the oss-licenses library:

compile 'com.google.android.gms:play-services-oss-licenses:11.4.0'

Displaying license information

When the application builds the gradle plugin will process the licenses, and add them to the app resources. To easily display them you can trigger an activity provided by the oss-licenses library at an appropriate point in your app:

import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;

//...

// When the user selects an option to see the licenses:
startActivity(new Intent(this, OssLicensesMenuActivity.class));

This will display a list of open source libraries that are compiled into the app, whether part of Google Play services or not. Tapping the library name will display the URL of the license.

Setting the activity title

You can set the title of the displayed activity through passing a title string extra on the intent:

Intent intent = new Intent(this, OssLicensesMenuActivity.class);
String title = getString(R.string.custom_license_title);
intent.putExtra("title", title);
startActivity(intent);

How licenses are determined

Each AAR or JAR for a library contains a POM file which describes the contents of the archive. The gradle plugin processes the Licenses field in this file, if present.

See the POM format documentation for more on the licenses field.