I'm trying to add the Google Translate client library to my Android project per these instructions, which tells me to add this line to my dependencies in build.gradle of my library project (which is a dependency of my app project):
compile group: 'com.google.cloud', name: 'google-cloud-translate', version: '0.4.0'
But when I do, I get this error:
Error:Execution failed for task ':typeSmart:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\Users\Barry\.gradle\caches\modules-2\files-2.1\com.google.auto.value\auto-value\1.1\f6951c141ea3e89c0f8b01da16834880a1ebf162\auto-value-1.1.jar
File2: C:\Users\Barry\.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.9.11\e32303ef8bd18a5c9272780d49b81c95e05ddf43\jackson-core-asl-1.9.11.jar
File3: C:\Users\Barry\.gradle\caches\modules-2\files-2.1\com.google.inject\guice\4.0\f990a43d3725781b6db7cd0acf0a8b62dfd1649\guice-4.0.jar
I understand what the error means technically but not why it appears in this case. I tried to suppress it by adding a packagingOptions
block to my build.gradle per this answer (and others), but it didn't help (plus it's illegal).
It seems unlikely that Google would publish an API with internal inconsistencies. The problem may be specific to my environment. My app consists of a library module that contains most of my code. It's a dependency of the app module. I suspect that has something to do with it.
I'm using: Gradle 2.14.1; Android Studio 2.2.2; Build tools 25.0.0.
Have you successfully added the Google Translate client library to your Android project? If so, how?
Thanks in advance...
Putting the dependecies at the top and the packageOptions at the end
, not sure though, it worth a try? – Eggbeater