简体   繁体   English

Retrofit2 DuplicateFileException

[英]Retrofit2 DuplicateFileException

Hi im new to retrofit and I got this error: 嗨,我是新手,我收到了这个错误:

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.retrofit2/retrofit/pom.properties
    File1: C:\Users\LouDoms\Documents\PICZON\LoOck2\app\libs\retrofit-2.0.0-beta3.jar
    File2: C:\Users\LouDoms\.gradle\caches\modules-2\files-2.1\com.squareup.retrofit2\retrofit\2.0.0-beta3\97675641051febfee098903cc0eff62f2826e34e\retrofit-2.0.0-beta3.jar

I tried to include the packaging options but they didn't work. 我尝试包括包装选项,但是它们没有用。 Someone help me please as I don't know what to do or what to remove. 有人帮我,因为我不知道该怎么办或该删除什么。

My gradle looks like this: 我的摇篮看起来像这样:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.loudoms.loock"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
compile 'com.jakewharton:butterknife:7.0.1'
}

This question is because ModuleA and ModuleB has same jar(also this jar has META-INF direct), method is:create a new Module(select Library),then take the jar join to this Module's "libs" direct,then let ModuleA and ModuleB dependent this Module Library. 这个问题是因为ModuleA和ModuleB具有相同的jar(此jar也具有META-INF直接),方法是:创建一个新的Module(选择库),然后将jar直接加入到此Module的“库”中,然后让ModuleA和ModuleB依赖于此模块库。 In this way,no DuplicateFileException. 这样,就不会出现DuplicateFileException。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM