Error with Google Translate API (Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug, duplicate entry)

Error with Google Translate API (Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug, duplicate entry)

我正在尝试在我的应用程序中实现语言翻译功能,因此为了实现此功能,我正在使用 Gradle 依赖项:"com.google.cloud:google-cloud-translate:0.5.0" 在同步依赖项我收到以下警告:

同步后 Information:Gradle 任务 [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

警告:警告:调试时忽略依赖项 org.apache.httpcomponents:httpclient:4.0.1,因为它可能与 Android 提供的内部版本冲突。

警告:警告:调试忽略依赖项 org.json:json:20151123,因为它可能与 Android.

提供的内部版本冲突

警告:警告:调试时忽略依赖项 org.apache.httpcomponents:httpclient:4.0.1,因为它可能与 Android 提供的内部版本冲突。

警告:警告:调试忽略依赖项 org.json:json:20151123,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.apache.httpcomponents:httpclient:4.0.1 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.json:json:20151123 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.apache.httpcomponents:httpclient:4.0.1 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.json:json:20151123 在发布时被忽略,因为它可能与 Android 提供的内部版本冲突。 Information:BUILD成功

Information:Total 时间:4.54 秒 Information:0 个错误 Information:8 警告 Information:See 在控制台中完成输出

当我 运行 同步后的项目时,出现以下错误:

重复条目:com/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream.class

运行我的项目

后出现错误

Information:Gradle 任务 [:app:assembleDebug]

警告:警告:调试时忽略依赖项 org.apache.httpcomponents:httpclient:4.0.1,因为它可能与 Android 提供的内部版本冲突。

警告:警告:调试忽略依赖项 org.json:json:20151123,因为它可能与 Android.

提供的内部版本冲突

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 被调试忽略,因为它可能与提供的内部版本冲突 Android.

警告:警告:调试忽略依赖项 org.json:json:20151123,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.apache.httpcomponents:httpclient:4.0.1 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.json:json:20151123 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.apache.httpcomponents:httpclient:4.0.1 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:警告:依赖项 org.json:json:20151123 在发布时被忽略,因为它可能与 Android.

提供的内部版本冲突

警告:AndroidManifest.xml 已经定义了 debuggable(在 http://schemas.android.com/apk/res/android 中);使用清单中的现有值。

错误:任务“:app:transformClassesWithJarMergingForDebug”执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream.class

Information:BUILD失败 Information:Total 时间:38.0 秒 Information:1 错误 Information:9 警告 Information:See 在控制台中完成输出

您需要将其从库中排除。 你的 gradle

中应该有这样的东西
compile('com.google.cloud:google-cloud-translate:0.5.0') {
    exclude group: 'org.apache.httpcomponents'
}
finally.... i solved it by doing this

1. changing the google play services dependency version from 9.8.0 to 9.6.0.

 2.forcing google play services to install in "resolutionStrategy" section



 ie: `configurations.all {
        resolutionStrategy {
              force 'com.google.android.gms:play-services:9.6.0'
        }
    }`

note these are the main changes i did in my gradle:

     compile ('com.google.cloud:google-cloud-translate:0.5.0') {
                exclude group: 'io.grpc', module: 'grpc-all'
                exclude group: 'com.google.protobuf', module: 'protobuf-java'
                exclude group: 'com.google.api-client', module: 'google-api-client-appengine'
            }

and configurations to force dependencies to override some common classes 

    configurations.all {
            exclude group: "org.apache.httpcomponents", module: "httpclient"
            exclude group: 'org.json', module: 'json'
            resolutionStrategy {
                force 'com.google.code.findbugs:jsr305:1.3.9'
                force 'com.android.support:design:23.4.0'
                force 'com.android.support:support-v4:23.4.0'
                force 'com.android.support:appcompat-v7:23.4.0'
                force 'com.google.android.gms:play-services:9.6.0'
            }
        }