I am working at a commercial android application.
I am also using some libraries licensed under different license types some of them stating the following:
If the library has a "NOTICE" file with attribution notes, you must include that NOTICE when you distribute
(One of them is licensed under Apache License 2.0 for example).
There is more than one library. When I do the build with gradle or with Android Studio I obtain the following build error:
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/license.txt
The answers that I found until now on the internet and stackoverflow suggest to remove the license.txt(notice.txt or other files that could interfere like this) from packaging by adding to build.gradle
file the following:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
See for example: Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt
According to the license of those libraries(Apache License 2.0 for instance), the license and notice files should be included.
My question: How can I add multiple files related to licensing(such as license.txt, notice.txt etc) from gradle into my project in order to be compliant with the licenses(technical detail: licences texts will be concatenated)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…