Android Gradle plugin 0.7.0: “duplicate files during packaging of APK”

后端 未结 20 2495
谎友^
谎友^ 2020-11-22 08:51

Using Android Gradle plugin 0.7.0 with the following build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }

    dependenci         


        
20条回答
  •  失恋的感觉
    2020-11-22 09:11

    If you want to do your part as developer, utilizing open source libraries, you should try including all those open source licenses within your apk. To do this, you can use the merge method in your packagingOptions.

    Example:

    packagingOptions {
            // This will get include every license and notice regardless of what dir it’s in.
            merge '**/LICENSE.txt'
            merge '**/NOTICE.txt'
            merge '**/notice.txt'
            merge '**/license.txt'
            merge '**/NOTICE'
            merge '**/LICENSE'
            merge '**/notice'
            merge '**/license'
            merge '**/LGPL2.1'
            // This will exclude any README files, regardless of the dir or the file type.
            exclude '**/README.*'
    }
    

    This answer is better than using pickFirst because that method only picks the first license it finds and disregards all the rest, kinda rendering it useless in this case.

    So in short, use the merge method to include all those licenses from those kickass open source libraries you’ve been using.

    More info on Gradle PackagingOptions.

提交回复
热议问题