11
18

More than 1 year has passed since last update.

[Android]公式のOSS表示ライブラリ

Last updated at Posted at 2020-04-23

はじめに

Androidアプリを作成していると様々なライブラリを使用する中で、
ライブラリを表示する必要があるかと思います。
今回はAndroid公式のライブラリを使用して表示する方法を記載していきます。

公式
Including Open Source Notices

環境

OS:Windows 10
Android Studio:3.5
言語:Kotlin

導入

1.build.gradle (Project)

buildscript {
    
    repositories {
        // なければ追加
        google()
        mavenCentral()
    }

    dependencies {
        // 追加
        classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'
    }
}

2.build.gradle (app)


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
// 追加
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    // 追加
    implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
}

3.Build実行

Project/app/build/generated/third_party_licenses/res/raw/に以下の2ファイルが生成
・third_party_license_metadata
・third_party_licenses

4.ライセンス画面の呼び出し

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

val intent = Intent(this, OssLicensesMenuActivity::class.java)
startActivity(intent)

参考文献

Including Open Source Notices (公式)
https://developers.google.com/android/guides/opensource

11
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
18