Reputation: 2308
In our (Android / IOS) application we using various third party libraries, for example GSON (for Android). In IOS it is possible to read data from the POD (example license info) and display it within the app.
Is there a way to do something similar in Android / Gradle?
To clarify, using Gradle I compile in the following dependencies:
compile 'com.koushikdutta.ion:ion:2.1.+'
compile 'com.google.code.gson:gson:2.6.+'
I'd like to have a screen in my application that shows the LICENSE files
https://github.com/google/gson/blob/master/LICENSE https://github.com/koush/ion/blob/master/LICENSE
The license retrieval need not happen within the app's Java code, it could be done at compile time, with this kind of logic inside Gradle:
for each dependency package check for LICENSE file concatenate LICENCE file into res/licenses.txt endfor
in app, have some code to show licenses.txt (or licenses.xml if required)
Upvotes: 1
Views: 1984
Reputation: 21
I will reply to the old post. A library for doing it has been added recently. https://developers.google.com/android/guides/opensource
These include the Gradle plugin "com.google.gms.oss.licenses.plugin" for getting license information from pom of the dependent library, It consists of the library "play-services-oss-licenses" which provides Activity to display licenses.
By adding it to the dependencies and building it, a file is generated in the app/src/main/res/raw directory that lists the license information of the library that the project depends on.
After that, you can display the license list screen by calling Activity as shown below.
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
val intent = Intent(this, OssLicensesMenuActivity::class.java)
intent.putExtra("title", "Open source license")
startActivity(intent)
Upvotes: 2