android studio Duplicate files copied in APK META-INF/NOTICE

报以下错误:

Error:Execution failed for task ':lvchedingdang:packageDebug'.
> Duplicate files copied in APK META-INF/NOTICE
File 1: D:\AndroidSutdioWShop\lvchedingdang\libs\httpcore-4.4-beta1.jar
File 2: D:\AndroidSutdioWShop\lvchedingdang\libs\httpmime-4.4-beta1.jar


解决方法:在build.gradle的android对象节点下边

增加蓝色jar包不编译选项(packagingOptions 


apply plugin: 'com.android.application'
//Android annotations
apply plugin: 'android-apt'
def AAVersion = '3.3.1'


android {
    compileSdkVersion  22
    buildToolsVersion "22.0.1"


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



    defaultConfig {
        applicationId "com.lvche.lvchedingdang"
        minSdkVersion 9
        targetSdkVersion  22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    //最大堆处理
    dexOptions {
        incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v4:22.0.0'
    //Android annotations编译jar包路径
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile project(':lvcheapplib')
}


//Android annotations
apt {
    arguments {
        //老版本的写法2.2.1以前
        //androidManifestFile variant.processResources.manifestFile
        //2.2.1以后
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName 'com.lvche.lvchedingdang'//项目包名
    }
}



你可能感兴趣的:(android studio Duplicate files copied in APK META-INF/NOTICE)