Duplicate files copied in APK META-INF/maven/com.squareup.okio/okio/pom.properties

我在导入okhttp包时出现以下问题:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException:Duplicate files copied in APK META-INF/maven/com.squareup.okio/okio/pom.properties
File1: C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\com.squareup.okio\okio\1.6.0\abc\okio-1.6.0.jar
File2: E:\android_studio\syc\app\build\intermediates\exploded-aar\com.umeng\message\2.4.1\jars\libs\com.umeng.message.lib_v2.4.1.jar

问题:Android Studio 引入冲突的jar包之后,会出现类似的错误。

解决方案:引入packagingOptions

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.plusend.weather"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 4
        versionName "1.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml'
        exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties'
        exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
        exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
    }
}

运行之后完美解决OK!

参考地址:http://blog.csdn.net/plusend/article/details/50243105

你可能感兴趣的:(Android,studio)