googlesamples / androidtv-sample-inputs

Sample Channel App (TV Input Service) on Android TV using TIF
https://developer.android.com/training/tv/tif
Apache License 2.0
491 stars 241 forks source link

DuplicateRelativeFileException: More than one file was found with OS independent path #25

Open clhols opened 7 years ago

clhols commented 7 years ago

When trying to build my project with the dependency:

com.google.android.libraries.tv:companionlibrary:0.2

I get the following error:

Error:com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'

I looks like this file is inside the com.google.ads.interactivemedia.v3:interactivemedia library that the companionlibrary depends on.

I tried to exclude it:

implementation('com.google.android.libraries.tv:companionlibrary:0.2') {
        exclude group: 'com.google.android.gms', module: 'play-services-ads'
        exclude group: 'com.google.ads.interactivemedia.v3', module: 'interactivemedia'
    }

But then it fails in onCreateSession with: java.lang.Class<com.google.android.media.tv.companionlibrary.AdController>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/ads/interactivemedia/v3/api/AdErrorEvent$AdErrorListener;

Fleker commented 7 years ago

What other imports are you using in your project? Is there a reason you're using implementation over compile? What happens if you use version 0.1?

clhols commented 7 years ago

I am using:

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

    implementation 'com.google.android.libraries.tv:companionlibrary:0.2'

    implementation 'com.google.android.exoplayer:exoplayer:r2.5.1'
    //implementation project(':exoplayer-lib')
    //implementation project(':exoplayer-library')

    implementation 'org.jetbrains.anko:anko-sdk15:0.10.1'
    implementation 'com.github.bumptech.glide:glide:4.2.0'
    implementation "com.github.bumptech.glide:okhttp3-integration:4.2.0"
    implementation 'com.squareup.okhttp3:okhttp:3.9.0'
    implementation "com.android.support:design:$supportLibVersion"
    implementation "com.android.support:support-v4:$supportLibVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation "com.google.android.gms:play-services-gcm:$playServicesVersion"

    implementation 'android.arch.lifecycle:extensions:1.0.0'
    implementation 'android.arch.lifecycle:reactivestreams:1.0.0'
    annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'

    implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
    implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

I stopped using compile when Gradle introduced implementation and api: https://docs.gradle.org/current/userguide/java_library_plugin.html

The 0.1 version has the same issue.

I have now copied the library module and removed the AdController and dependency on com.google.ads.interactivemedia.v3:interactivemedia. Now it works much better.

Fleker commented 7 years ago

Looks like the lib is using a pretty old version of Google Play Services which may cause a conflict with the newer version. Perhaps there needs to be some dependency updates to the lib overall.

SohailZahidGit commented 6 years ago

@Fleker is your issue solved just by Updating google Play Service?

Fleker commented 6 years ago

This is how I currently have the project included in a build.gradle:

// TV Input Framework
implementation('com.google.android.libraries.tv:companionlibrary:0.2') {
    exclude group: "com.google.ads.interactivemedia.v3"
    exclude group: "com.google.android.gms"
    exclude group: "com.android.support"
}

I do have more modernization on the way.

SohailZahidGit commented 6 years ago

@Fleker My problem solved just by replacing jar files with their gradle versions.

Tripati commented 5 years ago

In my app, I was adding the jar dependencies like this:

implementation files('libs/json-simple-1.1.1.jar') But I realised that they were already added because of the following first line in dependencies:

implementation fileTree(include: ['*.jar'], dir: 'libs') This line adds all the jars in lib folder to app dependency.

Hence after removing the extra dependency implementation files('libs/json-simple-1.1.1.jar')

it is working fine.

ralphgabrielle commented 5 years ago

Anyone use this and got it working ? There seems to be a problem with this Repository.

Also @integer/google_play_services_version file is missing

For Update :

packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/rxjava.properties'

        exclude 'error_prone/Annotations.gwt.xml'

        exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
    }
AlbertEinsteinGlitchPoint commented 5 years ago

hi guys i am having the same issue compiling it on android studio build gradle 3.1.0

and having the same error but ralphgabrielle solution did not owrk form me

jackykarma commented 5 years ago

I have change playServicesVersion = '18.1.1' version from 12.0.0 to 18.1.1, it works.

sanudatta11 commented 5 years ago

So whats the final solution for this ?

heitorri commented 4 years ago

Hi, Only put the code in my gradle:

packagingOptions { exclude 'error_prone/Annotations.gwt.xml' exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml' exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml' exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml' }

manojitballav commented 4 years ago

Adding @heitorri solution to build.gradle (Module: app) fixes the problem

heitorri commented 4 years ago

I will open a pull request for this :D

ritchieg9 commented 4 years ago

This solve my problem implementation('com.google.android.libraries.tv:companionlibrary:0.4.1') { exclude group: "com.google.android.gms" }