How to list Third-Party Dependencies Licenses in your Android app

In this tutorial, I’m going to show you how to implement a method that shows the licenses of the third-party dependencies automatically, using the OSS Licenses plugin made from Google.

Adding the OSS Licenses plugin

Go to the root-level build.gradle of your project and add the following line inside the dependencies { … }

buildscript { // ... dependencies { // ... classpath '' } } // ...
Code language: Kotlin (kotlin)

Next, go to the app-level build.gradle of your app, add the following library, and apply the plugin at the bottom:

dependencies { // ... implementation '' // ... } apply plugin: ''
Code language: Kotlin (kotlin)

Showing dependencies licenses

You can show the licenses of your dependencies by calling the following line inside a listener.

// ... license_btn.setOnClickListener { startActivity(Intent(this, } // ...
Code language: Kotlin (kotlin)

Customizing the OSS Licenses Activity

Changing Title

Change the title of the OSS Licenses Menu Activity by adding the following line before you call the activity:

license_btn.setOnClickListener { OssLicensesMenuActivity.setActivityTitle("Third-Party Licenses") // ... }
Code language: Swift (swift)

Changing Theme

Use a different theme for OSS Licenses Menu Activity and OSS Licenses Activity by adding the following in your AndroidManifestl.xml (manifests > AndroidManifest.xmll)

<activity android:name="" android:theme="@style/MyCustomTheme" /> <activity android:name="" android:theme="@style/MyCustomTheme" />
Code language: HTML, XML (xml)
You can find the final project here

If you have any questionsplease feel free to leave a comment below

Notify of
Inline Feedbacks
View all comments