Manu
Manu

Reputation: 147

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

i am trying to implement language translate feature in my app, so to implement this feature i am using Gradle Dependency :"com.google.cloud:google-cloud-translate:0.5.0" after syncing the dependencies i am getting following warnings:

After Syncing Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for release as it may be conflicting with the internal version provided by Android. Information:BUILD SUCCESSFUL

Information:Total time: 4.54 secs Information:0 errors Information:8 warnings Information:See complete output in console

when i run the project after sync i am getting following error:

duplicate entry: com/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream.class

Errors after running my project

Information:Gradle tasks [:app:assembleDebug]

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:WARNING: Dependency org.json:json:20151123 is ignored for release as it may be conflicting with the internal version provided by Android.

Warning:AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream.class

Information:BUILD FAILED Information:Total time: 38.0 secs Information:1 error Information:9 warnings Information:See complete output in console

Upvotes: 1

Views: 965

Answers (2)

Manu
Manu

Reputation: 147

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

Upvotes: 2

Alex
Alex

Reputation: 3382

You need to exclude it from the lib. You should have something like this in your gradle

compile('com.google.cloud:google-cloud-translate:0.5.0') {
    exclude group: 'org.apache.httpcomponents'
}

Upvotes: 0

Related Questions