Development Tip

APK META-INF / license.txt에 복사 된 Android Gradle 중복 파일

yourdevel 2020. 10. 17. 12:30
반응형

APK META-INF / license.txt에 복사 된 Android Gradle 중복 파일


나는 여기에 설명 된대로 내 안드로이드 응용 프로그램에 봄과 RESTful 웹 서비스 지원을 추가 할거야 https://spring.io/guides/gs/consuming-rest-android/ .

이것은 최상위 build.gradle 구성입니다.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

이것은 내 app/build.gradle구성입니다.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example"
        minSdkVersion 8
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    dependencies {
        compile 'com.android.support:appcompat-v7:+'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
        compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
    }

    packagingOptions {
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
    }

}

지금은 다음 오류와 함께 실패합니다.

FAILURE: Build failed with an exception.

* 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
    File1: user\.gradle\caches\modules-2\files-2.1\org.springframework.android\spring-android-rest-template\1.0.1.RELEASE\e132d929bd181941f79b0d63edafb8a86ae6fd33\spring-android-rest-template-1.0.1.RELEASE.jar
    File2: user\.gradle\caches\modules-2\files-2.1\org.springframework.android\spring-android-core\1.0.1.RELEASE\e68f0e8e4b636ee30c4de58953be38d9b72a5e3b\spring-android-core-1.0.1.RELEASE.jar

내가 뭘 잘못하고 어떻게 고칠 수 있습니까?


앱 수준 gradle 파일에서 아래 줄을 작성하십시오.

android {
    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'
    }
}

선택한 답변의 해결 방법으로 문제가 해결되지 않으면 추가해보십시오.

    exclude 'META-INF/ASL2.0'

게다가. 또는 기본적으로 중복 파일의 이름을 식별하고 제외합니다. 위의 추가로 문제가 해결되었습니다.


그것은 나를 돕는다. 이 코드를 시도하십시오 :)

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

이 줄을 추가하면 도움이되었습니다.

shadowJar {
    // Filtering shadow jar contents by file pattern.
    exclude 'schemaorg_apache_xmlbeans/attribute/**'
    exclude 'schemaorg_apache_xmlbeans/attributegroup/**'
    exclude 'schemaorg_apache_xmlbeans/element/**'
    exclude 'schemaorg_apache_xmlbeans/identityconstraint/**'
    exclude 'schemaorg_apache_xmlbeans/javaname/**'
    exclude 'schemaorg_apache_xmlbeans/modelgroup/**'
    exclude 'schemaorg_apache_xmlbeans/namespace/**'
    exclude 'schemaorg_apache_xmlbeans/src/**'
    exclude 'schemaorg_apache_xmlbeans/system/sXML*/**'
    exclude 'schemaorg_apache_xmlbeans/system/s8C3F193EE11A2F798ACF65489B9E6078/**'
    exclude 'schemaorg_apache_xmlbeans/type/**'

    exclude 'repackage/**'

    exclude 'LICENSE.txt'
    exclude 'NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/maven/**'

    // these are only needed when handling Visio files, remove it if you would like to use Visio support
    dependencies {
        exclude(dependency('com.github.virtuald:curvesapi'))
        exclude(dependency('commons-codec:commons-codec'))
    }

    // Relocate javax dependencies so Android does not choke
    relocate 'javax.xml.namespace', 'org.apache.poi.javax.xml.namespace'
    relocate 'javax.xml.stream', 'org.apache.poi.javax.xml.stream'
    relocate 'javax.xml.XMLConstants', 'org.apache.poi.javax.xml.XMLConstants'
}

이것은 나를 위해 일했습니다.

    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'
    exclude 'META-INF/spring.schemas'
    exclude 'META-INF/spring.tooling'
    exclude 'META-INF/INDEX.LIST'
    exclude 'META-INF/spring.handlers'
}
configurations {
    all*.exclude module: 'classworlds'
    all*.exclude module: 'commons-logging'
    all*.exclude module: 'httpclient'
    all*.exclude module: 'maven-artifact'
    all*.exclude module: 'maven-artifact-manager'
    all*.exclude module: 'maven-error-diagnostics'
    all*.exclude module: 'maven-model'
    all*.exclude module: 'maven-project'
    all*.exclude module: 'maven-settings'
    all*.exclude module: 'plexus-container-default'
    all*.exclude module: 'plexus-interpolation'
    all*.exclude module: 'plexus-utils'
    all*.exclude module: 'wagon-file'
    all*.exclude module: 'wagon-http-lightweight'
    all*.exclude module: 'wagon-provider-api'

}

참고URL : https://stackoverflow.com/questions/37586800/android-gradle-duplicate-files-copied-in-apk-meta-inf-license-txt

반응형