复制的文件重复

时间:2016-04-04 12:33:07

标签: android build

我正在使用Android Studio开发一个应用程序,我需要调用rest api。我做了所有步骤,在build.gradle中添加了所需的jar。当我重建项目时似乎很好。但是当我试图在模拟器中运行它时,它会显示以下错误。我尝试了几乎所有可用的解决方案,排除了所有但未解决我的问题。

  

错误:任务':app:transformResourcesWithMergeJavaResForDebug'执行失败。   com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK META-INF / services / org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable中复制的重复文件       File1:C:\ Users \ everstek 1.gradle \ _caches \ modules-2 \ files-2.1 \ org.glassfish.jersey.core \ jersey-server \ 2.22.1 \ 20eee7b976e7005a40f05c0965dd76a308689e98 \ jersey-server-2.22.1.jar       File2:C:\ Users \ everstek 1.gradle \ _caches \ modules-2 \ files-2.1 \ org.glassfish.jersey.media \ jersey-media-jaxb \ 2.22.1 \ 1bc910febfe9e07f741920ff5ac24bb8a59f649f \ jersey-media-jaxb-2.22。 1.jar

任何人都可以提供帮助。提前谢谢。

  

这是我的build.gradle中的条目   //编译文件(' src / main / libs / guava-18.0.jar')       编译' com.google.guava:guava:18.0'

//compile files('src/main/libs/hk2-api-2.4.0-b31.jar')
compile 'org.glassfish.hk2:hk2-api:2.4.0-b31'

//compile files('src/main/libs/hk2-locator-2.4.0-b31.jar')
compile 'org.glassfish.hk2:hk2-locator:2.4.0-b31'

//compile files('src/main/libs/hk2-utils-2.4.0-b31.jar')
compile 'org.glassfish.hk2:hk2-utils:2.4.0-b31'

//compile files('src/main/libs/javax.annotation-api-1.2.jar')
compile 'javax.annotation:javax.annotation-api:1.2'

//compile files('src/main/libs/javax.inject-1.jar')
compile 'javax.inject:javax.inject:1'

//compile files('src/main/libs/javax.ws.rs-api-2.0.1.jar')
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'

//compile files('src/main/libs/jersey-apache-connector-2.22.1.jar')
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.22.1'

//compile files('src/main/libs/jersey-client-2.22.1.jar')
compile 'org.glassfish.jersey.core:jersey-client:2.22.1'

//compile files('src/main/libs/jersey-common-2.22.1.jar')
compile 'org.glassfish.jersey.core:jersey-common:2.22.1'

//compile files('src/main/libs/jersey-guava-2.22.1.jar')
compile 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.1'

//compile files('src/main/libs/jersey-media-multipart-2.22.1.jar');
compile 'org.glassfish.jersey.media:jersey-media-multipart:2.22.1'

//compile files('src/main/libs/jersey-server-2.22.1.jar')
compile 'org.glassfish.jersey.core:jersey-server:2.22.1'

//compile files('src/main/libs/logback-classic-1.1.3.jar')
compile 'ch.qos.logback:logback-classic:1.1.3'

//compile files('src/main/libs/logback-core-1.1.3.jar')
compile 'ch.qos.logback:logback-classic:1.1.3'

//compile files('src/main/libs/mimepull-1.9.6.jar');
compile 'org.jvnet.mimepull:mimepull:1.9.6'

//compile files('src/main/libs/slf4j-api-1.7.12.jar')
compile 'org.slf4j:slf4j-android:1.7.12'

2 个答案:

答案 0 :(得分:0)

jersey-guava和jersey-common包含在球衣客户端依赖中。您不需要添加每个个体。此外,如果应用程序是客户端,则Android应用程序不需要服务器依赖性。

尝试清理您的项目,但看起来您正在使用jersey-server repo。

删除您当前的球衣依赖性,运行'清洁' gradle任务,并添加此依赖项:

dependencies {
   //other dependencies
   compile 'org.glassfish.jersey.core:jersey-client:2.22.2'
}

如果您更愿意使用jersey 2.22.1,只需更改依赖项中的版本号即可。

答案 1 :(得分:0)

此解决方案我显示了一些警告但工作正常

We have to add dependency in group manner that will help us to understood better. For My Above Question I Have To Add This In Dependency


compile group: 'com.google.guava', name: 'guava', version: '19.0'
//compile files('libs/guava-18.0.jar')
compile group: 'org.glassfish.hk2', name: 'hk2-api', version: '2.5.0-b06'
//compile files('libs/hk2-api-2.4.0-b31.jar')
compile group: 'org.glassfish.hk2', name: 'hk2-locator', version: '2.5.0-b06'
//compile files('libs/hk2-locator-2.4.0-b31.jar')
compile group: 'org.glassfish.hk2', name: 'hk2-utils', version: '2.5.0-b06'
//compile files('libs/hk2-utils-2.4.0-b31.jar')
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.2'
//compile files('libs/javax.annotation-api-1.2.jar')
compile group: 'javax.inject', name: 'javax.inject', version: '1'
//compile files('libs/javax.inject-1.jar')
compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.0.1'
//compile files('libs/javax.ws.rs-api-2.0.1.jar')
compile group: 'org.glassfish.jersey.connectors', name: 'jersey-apache-connector', version: '2.23.1'
//compile files('libs/jersey-apache-connector-2.22.1.jar')
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.23.1'
//compile files('libs/jersey-client-2.22.1.jar')
compile group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.23.1'
//compile files('libs/jersey-common-2.22.1.jar')
compile group: 'org.glassfish.jersey.bundles.repackaged', name: 'jersey-guava', version: '2.23.1'
//compile files('libs/jersey-guava-2.22.1.jar')
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: '2.23.1'
//compile files('libs/jersey-media-multipart-2.22.1.jar')
//compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version: '2.23.1'
//compile files('libs/jersey-server-2.22.1.jar')
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
//compile files('libs/logback-classic-1.1.3.jar')
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.1.7'
//compile files('libs/logback-core-1.1.3.jar')
compile group: 'org.jvnet.mimepull', name: 'mimepull', version: '1.9.6'
//compile files('libs/mimepull-1.9.6.jar')
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'