LicensesDialog
Androidアプリの作成に使ったライブラリのライセンスをアプリにすばやく組み込むにはLicensesDialogがおすすめです。
インストール
下のエラーが発生してインストールできない困ったw
Warning:Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (3.0.1) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.
Dependency Error. See console for details.
エラーを回避
下を追加したら動いた
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
全体
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "jp.co.test.licensedialog"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//追加
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
//追加
compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
アクティビティで表示
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showLicense();
}
private void showLicense() {
final Notices notices = new Notices();
notices.addNotice(
new Notice("butterknife", "", "Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
notices.addNotice(
new Notice("timber", "", "Copyright 2013 Jake Wharton", new ApacheSoftwareLicense20()));
notices.addNotice(
new Notice("material-dialogs", "","Copyright (c) 2014-2016 Aidan Michael Follestad", new MITLicense()));
final LicensesDialogFragment fragment = new LicensesDialogFragment.Builder(getApplicationContext())
.setNotices(notices)
.setShowFullLicenseText(false)
.setIncludeOwnLicense(true)
.build();
fragment.show(getSupportFragmentManager(), null);
}
}