Android Gradle在APK META-INF / license.txt中复制的重复文件

时间:2017-05-09 01:56:44

标签: javascript android android-studio-2.2

错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。 > com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / LICENSE File1中复制的重复文件:C:\ Users \ hdeka.gradle \ caches \ modules-2 \ files -2.1 \融为一体

1 个答案:

答案 0 :(得分:1)

您可以在app gradle文件中添加几行代码,以消除该错误。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "YourAppId"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }
    // these are the lines that you have to add
    packagingOptions {
    exclude 'META-INF/LICENSE'
    //include below line if you are using firebase
    //exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

让我知道它是否有效。 : - )