GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Dependency conflict when adding google-cloud-translate to Android app. · Issue #1361 · googleapis/google-cloud-java

Dependency conflict when adding google-cloud-translate to Android app. #1361

New issue
Copy link
New issue
Copy link
Closed
Closed
Dependency conflict when adding google-cloud-translate to Android app.#1361
Copy link
Assignees
BarryFruitman

Description

@BarryFruitman
BarryFruitman
opened on Nov 1, 2016
Issue body actions

This is essentially a dupe of issue #1319 but with Google Translate.

I added the Google Translate Java client library to my Android app per these instructions, which consists of adding this line to my build.gradle file 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'

However when I build, 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 tried all the suggestions in the other issue but I'm happy to go over them again.

I'm using the latest version of Android Studio (2.2.2) with the Gradle wrapper.

Any help is much appreciated. Thanks in advance!

Activity

Next
  1. mziccard commented on Nov 1, 2016

    @mziccard
    mziccard
    on Nov 1, 2016
    Contributor
    More actions

    Hi @BarryFruitman, please notice that we do not explicitly support Android, hence the issues you are getting. Let me try to help you though.

    Have you tried to get rid of duplications by doing:

    packagingOptions {
        pickFirst 'META-INF/LICENSE'
        pickFirst  'META-INF/io.netty.versions.properties'
        pickFirst 'META-INF/INDEX.LIST'
    }

    If yes, what happens?

  2. BarryFruitman commented on Nov 1, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 1, 2016
    Author
    More actions

    @mziccard Thanks for your prompt reply. I get the exact same exception. :(

    (For the record, where am I supposed to add packagingOptions? The only places I could were inside the android and defaultConfig blocks of the module build.gradle file. Neither had any effect.)

  3. mziccard commented on Nov 1, 2016

    @mziccard
    mziccard
    on Nov 1, 2016
    Contributor
    More actions

    packagingOptions should go inside the android block in your build.gradle.

    I get the exact same exception. :(

    This is very strange. Have you done a clean build? Are you still getting a duplicate complaint for META-INF/LICENSE or for a different file?

    Let's try something more aggressive:

    packagingOptions { 
         exclude 'META-INF/LICENSE'
         exclude 'META-INF/io.netty.versions.properties'
         exclude 'META-INF/INDEX.LIST'
    }
  4. BarryFruitman commented on Nov 1, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 1, 2016
    Author
    More actions

    @mziccard Yes I've done many clean builds. I've blown away ~/.gradle too. I've also already tried many variations of the packagingOptions solution that I found on Stack Overflow. :(

    Is it possible to statically link the library? Do you have any other suggestions?

  5. mziccard commented on Nov 1, 2016

    @mziccard
    mziccard
    on Nov 1, 2016
    Contributor
    More actions

    @BarryFruitman you did not answer to my question: "Are you still getting a duplicate complaint for META-INF/LICENSE or for a different file?"

    There must be something wrong with your build file. I have been able to reproduce your issue and work around it using excludes. I suggest you do a thorough check of your build file.

    Alternatively, you can use the translate API referenced here.

  6. BarryFruitman commented on Nov 1, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 1, 2016
    Author
    More actions

    @mziccard Same file. Sorry that's what I meant when I said exact same exception. :)

    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
    
  7. BarryFruitman commented on Nov 1, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 1, 2016
    Author
    More actions

    I just created a brand new Android project and added the Google Translate library and the packagingOptions fix and I got yet another exception. That's the third one so far from adding Google Cloud libs, and they all happen in transformResourcesWithMergeJavaResForDebug.

    I'm just gonna wait until the libs are ready for Prime Time. ;)

    Thanks for your help!

  8. BarryFruitman
    closed this as completedon Nov 1, 2016
  9. mziccard commented on Nov 1, 2016

    @mziccard
    mziccard
    on Nov 1, 2016
    Contributor
    More actions

    and I got yet another exception

    Care to share? :)

  10. BarryFruitman commented on Nov 1, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 1, 2016
    Author
    More actions

    I'm really sorry but I already deleted the project.

    Please consider updating the docs to point out the Android incompatibility. It would have saved me a lot of time.

  11. mziccard commented on Nov 3, 2016

    @mziccard
    mziccard
    on Nov 3, 2016
    Contributor
    More actions

    @BarryFruitman In case you are still interested this example shows a working Android app using google-cloud-translate 0.5.0.

  12. BarryFruitman commented on Nov 3, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 3, 2016
    Author
    More actions

    Thanks for following up. I can build and deploy your example project. However I still cannot build my own project. I added the two compile dependencies and packagingOptions to my build.gradle. Here are my dependencies:

    dependencies {
        compile 'com.android.support:support-compat:25.0.0'
        compile files('libs/voiceimeutils.jar')
    
        compile ('com.google.apis:google-api-services-translate:v2-rev47-1.22.0') {
            exclude group: 'com.google.guava'
        }
        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'
        }
    }
    

    It fixed one of the duplicates. Now I only get two of the three original conflicts:

    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.inject\guice\4.0\f990a43d3725781b6db7cd0acf0a8b62dfd1649\guice-4.0.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
    

    At least it's progress! Should I have copied anything else from your example project?

  13. mziccard commented on Nov 3, 2016

    @mziccard
    mziccard
    on Nov 3, 2016
    Contributor
    More actions

    @BarryFruitman the relevant bits from the example are the following (see the example's build.gradle to see where to put them):

    • Enable multidex:
        defaultConfig {
            ...
            multiDexEnabled true
        }
    • Force findbugs resolution strategy:
        configurations.all {
            resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
        }
    • Exclude duplicate files:
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/io.netty.versions.properties'
            exclude 'META-INF/INDEX.LIST'
        }
    • Import google-cloud-translate avoiding duplicates:
        compile ('com.google.apis:google-api-services-translate:v2-rev47-1.22.0') {
            exclude group: 'com.google.guava'
        }
        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'
        }
    

    If this is in place you should not have problems running your app. Please double check and do a clean build.

    Reacted by Nabin Khatiwada
  14. BarryFruitman commented on Nov 4, 2016

    @BarryFruitman
    BarryFruitman
    on Nov 4, 2016
    Author
    More actions

    I still get the same exception. I tried a clean build in both the IDE and command line. I even blew away ~/.gradle.

    The silver lining is now the command line reports the same error as the IDE. :-P

  15. Osoter commented on Nov 22, 2016

    @Osoter
    Osoter
    on Nov 22, 2016
    More actions

    I've the same problem of Barry.

    `apply plugin: 'com.android.application'

    android {
    compileSdkVersion 24
    buildToolsVersion 24.0.1

    defaultConfig {
        applicationId "com.blabla.app"
        minSdkVersion 22
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/io.netty.versions.properties'
        exclude 'META-INF/INDEX.LIST'
    }
    

    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:25.0.1'
        compile 'com.android.support:design:25.0.1'
        compile 'com.google.code.findbugs:jsr305:2.0.1'
        compile 'com.google.apis:google-api-services-storage:+'
        testCompile 'junit:junit:4.12'
        compile project(path: ':backend', configuration: 'android-endpoints')
        compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
        compile 'com.android.volley:volley:1.0.0'
        compile 'com.google.apis:google-api-services-vision:v1-rev30-1.22.0'
        compile ('com.google.cloud:google-cloud-translate:0.6.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'
        }
        
    }
    repositories{
        mavenCentral()
    }
    
    dependencies {
     
        compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
    }
    
    `
    
  16. 22 remaining items

  17. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore: update github actions (#1361) (#881)

    ded0b2b
  18. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    chore: update github actions (googleapis#1361) (googleapis#768)

    94bc10e

    build: stop auto merging releases (googleapis#1361)

    b6ad295
  19. suztomo
    added 2 commits that reference this issue on Mar 30, 2026

    chore: update github actions (#1361) (#834)

    d23b996

    chore(deps): update dependency com.google.cloud:google-cloud-nio to v…

    3a3d3dc
  20. lqiu96
    added 2 commits that reference this issue on Apr 1, 2026

    chore: update github actions (#1361) (#834)

    f37f405

    chore(deps): update dependency com.google.cloud:google-cloud-nio to v…

    f50df15
  21. meltsufin
    added 6 commits that reference this issue on Apr 29, 2026

    chore: update github actions (#1361) (#1034)

    092c590

    deps: update dependency com.google.cloud:google-cloud-core to v2.8.22 (…

    0355868

    chore(main): release 1.120.23 (#1367)

    f1844eb

    chore: update github actions (#1361) (#1034)

    4807582

    deps: update dependency com.google.cloud:google-cloud-core to v2.8.22 (…

    e71dc8d

    chore(main): release 1.120.23 (#1367)

    8dd53dd
  22. benjaminp
    added 2 commits that reference this issue on Jul 13, 2026

    chore(main): release 2.11.1-SNAPSHOT (googleapis#1361)

    36667ee

    feat: Support Cloud Bigtable Changestream (googleapis#1569)

    99071f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @BarryFruitman
    BarryFruitman

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.