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

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

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

buildscript {
    repositories {
        mavenCentral()
    }

    dependenci         


        
20条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 09:24

    As of Android Studio version 0.8.14

    You should add:

     android {
         packagingOptions { 
             exclude 'META-INF/LICENSE.txt'
             exclude 'META-INF/NOTICE.txt'
             exclude '...'
         }
     }  
    

    to your build.gradle file.

    History:

    According to comment 14 in this bug: https://issuetracker.google.com/issues/36982149#comment14 this is a bug in v0.7.0 of the Android Gradle plugin, and is due to be fixed soon in 0.7.1.

    Here are the notes from that bug about the addition for 0.7.1:

    0.7.1 is out with the fix for this.

    The DSL to exclude files is:

    android {
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
        }
    }
    

    You can add as many exclude statement as you want. The value is the archive path. No wildcard or glob support yet.

    Filenames "LICENSE.txt" and "NOTICE.txt" are case sensitive. Please try out with "license.txt" and "notice.txt" as well.

提交回复
热议问题