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

后端 未结 20 2452
谎友^
谎友^ 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 08:59

    It's more than one error

    Under apply plugin: 'android-library'

    add this ::

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

    In case of duplicate files it's easy, look inside the JAR under the META-INF dir and see what's causing the error. It could be multiple. In my case Couchbase Lite plugin. As you add more plugins, you will need more exceptions

    0 讨论(0)
  • 2020-11-22 09:00

    Files "LICENSE.txt" and "NOTICE.txt" are case sensitive. So for SPring android library I had to add

    android {
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/notice.txt'
        }
    }
    
    0 讨论(0)
  • 2020-11-22 09:01

    I think you need to include only these options in build.gradle:

    packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
        }
    

    p.s same answer from my post in : Error :: duplicate files during packaging of APK

    0 讨论(0)
  • 2020-11-22 09:04

    In Android Studio 1.1.0 i needed lower case names:

    packagingOptions{
          exclude 'META-INF/license.txt'
          exclude 'META-INF/notice.txt'
    }
    
    0 讨论(0)
  • 2020-11-22 09:05

    The same problem when I export the library httclient-4.3.5 in Android Studio 0.8.6 I need include this:

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

    The library zip content the next jar:

    commons-codec-1.6.jar
    commons-logging-1.1.3.jar
    fluent-hc-4.3.5.jar
    httpclient-4.3.5.jar
    httpclient-cache-4.3.5.jar
    httpcore-4.3.2.jar
    httpmime-4.3.5.jar
    
    0 讨论(0)
  • 2020-11-22 09:05

    I noticed this commit comment in AOSP, the solution will be to exclude some files using DSL. Probably when 0.7.1 is released.

    commit e7669b24c1f23ba457fdee614ef7161b33feee69
    Author: Xavier Ducrohet <--->
    Date:   Thu Dec 19 10:21:04 2013 -0800
    
        Add DSL to exclude some files from packaging.
    
        This only applies to files coming from jar dependencies.
        The DSL is:
    
        android {
          packagingOptions {
            exclude 'META-INF/LICENSE.txt'
          }
        }
    
    0 讨论(0)
提交回复
热议问题