LoginSignup
0
1

More than 1 year has passed since last update.

Androidのlicense出力ライブラリとパーサー

Posted at

Androidのlicense一覧の自動抽出

Androidアプリが使用しているlicense一覧を自動抽出するライブラリが公開されています。
https://developers.google.com/android/guides/opensource

このライブラリを使用すると、license一覧画面が簡単に作れます。
1.jpg

パーサー

ただ、Activityが必要ですし、このUIを使いたくない場合もあります。

自分でUIを作るには、まずはこのライブラリが出力する下記ファイルをパースする必要があります。
third_party_licenses
third_party_license_metadata

下記ファイルについては、全ライブラリのlicenseの中身が入っております。

third_party_licenses
http://www.apache.org/licenses/LICENSE-2.0.txt
https://developer.android.com/studio/terms.html

   Copyright (c) 2005-2011, The Android Open Source Project

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
           :
           :

一方、下記ファイルについては、ライブラリ名と、そのライブラリのlicenseは
さきほどのファイルの何バイト目から何バイト目にあたるかが書かれております。

third_party_license_metadata
0:46 Android Support Library Cursor Adapter
0:46 Android Support Library Interpolators
0:46 Android Support Library Annotations

このままではlicense一覧画面を作れないので、パーサーを作りました。
今回はGo langで作っております。

パーサーの出力結果
ライブラリ1
licenseの内容

ライブラリ2
ライブラリ3
licenseの内容
     :
     :

このようなテキストファイルを出力するようにしました。
また、htmlでも出力するようにしました。

ソースはココ

参考文献

https://zenn.dev/chibatching/articles/google-license-data-parse

0
1
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
0
1