firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.28k stars 580 forks source link

Duplicate class com.google.common.util.concurrent.ListenableFuture after BOM update #1575

Closed KonradSzewczuk closed 4 years ago

KonradSzewczuk commented 4 years ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Bumping the firebase-bom from 24.5.0 -> 25.3.1 to be able to use Firebase Kotlin Extensions ends up in dependencies error

Steps to reproduce:

Create brand new Android Studio project including below dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation platform('com.google.firebase:firebase-bom:25.3.1')
    implementation "com.google.firebase:firebase-inappmessaging-display-ktx"
    implementation "com.google.firebase:firebase-firestore-ktx"
    implementation "androidx.browser:browser:1.2.0"
    implementation "androidx.work:work-runtime-ktx:2.4.0-alpha03"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

When you try to build and run the project below error occurs:

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android) and jetified-listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)

google-oss-bot commented 4 years ago

I found a few problems with this issue:

KonradSzewczuk commented 4 years ago

I can also confirm that this issue started to happen from firebase-bom version 24.7.1 and continue to happen (last working firebase-bom version was 24.7.0)

davidmotson commented 4 years ago

Thank you very much for the report! This is definitely not intended. Could you send along the dependency tree?

You can get it from your project by running the following command: ./gradlew app:dependencies

(replacing app with the name of your module if needed)

KonradSzewczuk commented 4 years ago

@davidmotson sure, you can find it below:

releaseRuntimeClasspath - Runtime classpath of compilation 'release' (target  (androidJvm)).
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.72
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72
|         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72
|         \--- org.jetbrains:annotations:13.0
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.72 (*)
+--- androidx.appcompat:appcompat:1.1.0
|    +--- androidx.annotation:annotation:1.1.0
|    +--- androidx.core:core:1.1.0 -> 1.2.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.1.0
|    |    |    +--- androidx.lifecycle:lifecycle-common:2.1.0
|    |    |    |    \--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.arch.core:core-common:2.1.0
|    |    |    |    \--- androidx.annotation:annotation:1.1.0
|    |    |    \--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.versionedparcelable:versionedparcelable:1.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0
|    |    |         \--- androidx.annotation:annotation:1.1.0
|    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.cursoradapter:cursoradapter:1.0.0
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    +--- androidx.fragment:fragment:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.core:core:1.1.0 -> 1.2.0 (*)
|    |    +--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.viewpager:viewpager:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    |    \--- androidx.customview:customview:1.0.0
|    |    |         +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |         \--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    +--- androidx.loader:loader:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.1.0
|    |    |    |    +--- androidx.arch.core:core-runtime:2.1.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    |    |    \--- androidx.arch.core:core-common:[2.1.0] -> 2.1.0 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.1.0
|    |    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.1.0 (*)
|    |    |    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    |    |    \--- androidx.arch.core:core-runtime:2.1.0 (*)
|    |    |    |    \--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.1.0
|    |    |         \--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.activity:activity:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.core:core:1.1.0 -> 1.2.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.1.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.1.0 (*)
|    |    |    \--- androidx.savedstate:savedstate:1.0.0
|    |    |         +--- androidx.annotation:annotation:1.1.0
|    |    |         +--- androidx.arch.core:core-common:2.0.1 -> 2.1.0 (*)
|    |    |         \--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.1.0 (*)
|    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.1.0 (*)
|    +--- androidx.appcompat:appcompat-resources:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.core:core:1.0.1 -> 1.2.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable:1.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.core:core:1.1.0 -> 1.2.0 (*)
|    |    |    \--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable-animated:1.1.0
|    |    |    +--- androidx.vectordrawable:vectordrawable:1.1.0 (*)
|    |    |    +--- androidx.interpolator:interpolator:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    \--- androidx.collection:collection:1.1.0 (*)
|    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.drawerlayout:drawerlayout:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    \--- androidx.customview:customview:1.0.0 (*)
|    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
+--- androidx.core:core-ktx:1.2.0
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.41 -> 1.3.72 (*)
|    +--- androidx.annotation:annotation:1.1.0
|    \--- androidx.core:core:1.2.0 (*)
+--- androidx.constraintlayout:constraintlayout:1.1.3
|    \--- androidx.constraintlayout:constraintlayout-solver:1.1.3
+--- com.google.firebase:firebase-bom:25.3.1
|    +--- com.google.firebase:firebase-inappmessaging:19.0.6 (c)
|    \--- com.google.firebase:firebase-firestore:21.4.3 (c)
+--- com.google.firebase:firebase-inappmessaging -> 19.0.6
|    +--- com.google.android.datatransport:transport-api:2.2.0
|    +--- com.google.android.gms:play-services-tasks:17.0.0
|    |    \--- com.google.android.gms:play-services-basement:17.0.0
|    |         +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |         +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |         \--- androidx.fragment:fragment:1.0.0 -> 1.1.0 (*)
|    +--- com.google.auto.value:auto-value-annotations:1.6.5
|    +--- com.google.dagger:dagger:2.24
|    |    \--- javax.inject:javax.inject:1
|    +--- com.google.firebase:firebase-abt:19.0.1
|    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-common:19.3.0
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    |    +--- com.google.auto.value:auto-value-annotations:1.6.5
|    |    |    \--- com.google.firebase:firebase-components:16.0.0
|    |    |         \--- androidx.annotation:annotation:1.1.0
|    |    +--- com.google.firebase:firebase-components:16.0.0 (*)
|    |    +--- com.google.firebase:firebase-measurement-connector:18.0.0
|    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    \--- com.google.protobuf:protobuf-lite:3.0.1
|    +--- com.google.firebase:firebase-common:19.3.0 (*)
|    +--- com.google.firebase:firebase-components:16.0.0 (*)
|    +--- com.google.firebase:firebase-datatransport:17.0.3
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- com.google.android.datatransport:transport-api:2.1.0 -> 2.2.0
|    |    +--- com.google.android.datatransport:transport-backend-cct:2.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- com.google.android.datatransport:transport-api:2.1.0 -> 2.2.0
|    |    |    +--- com.google.android.datatransport:transport-runtime:2.1.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    |    +--- com.google.android.datatransport:transport-api:2.1.0 -> 2.2.0
|    |    |    |    \--- com.google.dagger:dagger:2.22 -> 2.24 (*)
|    |    |    \--- com.google.protobuf:protobuf-lite:3.0.1
|    |    +--- com.google.android.datatransport:transport-runtime:2.1.0 (*)
|    |    \--- com.google.firebase:firebase-common:19.3.0 (*)
|    +--- com.google.firebase:firebase-iid:20.0.1
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |    |    +--- androidx.documentfile:documentfile:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    +--- androidx.loader:loader:1.0.0 (*)
|    |    |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    |    \--- androidx.print:print:1.0.0
|    |    |         \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-stats:17.0.0
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    +--- com.google.firebase:firebase-common:19.2.0 -> 19.3.0 (*)
|    |    \--- com.google.firebase:firebase-iid-interop:17.0.0
|    |         +--- com.google.android.gms:play-services-base:17.0.0
|    |         |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |         |    +--- androidx.core:core:1.0.0 -> 1.2.0 (*)
|    |         |    +--- androidx.fragment:fragment:1.0.0 -> 1.1.0 (*)
|    |         |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |         |    \--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |         \--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    +--- com.google.firebase:firebase-measurement-connector:18.0.0 (*)
|    +--- com.google.firebase:protolite-well-known-types:17.0.0
|    |    \--- com.google.protobuf:protobuf-lite:3.0.1
|    +--- io.grpc:grpc-okhttp:1.21.0
|    |    +--- io.grpc:grpc-core:[1.21.0] -> 1.21.0
|    |    |    +--- io.opencensus:opencensus-api:0.21.0
|    |    |    +--- io.grpc:grpc-api:[1.21.0] -> 1.21.0
|    |    |    |    +--- io.grpc:grpc-context:1.21.0
|    |    |    |    +--- com.google.errorprone:error_prone_annotations:2.3.2
|    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    |    |    +--- org.codehaus.mojo:animal-sniffer-annotations:1.17
|    |    |    |    \--- com.google.guava:guava:26.0-android
|    |    |    |         +--- org.checkerframework:checker-compat-qual:2.5.2
|    |    |    |         \--- com.google.j2objc:j2objc-annotations:1.1
|    |    |    +--- com.google.code.gson:gson:2.7
|    |    |    +--- com.google.android:annotations:4.1.1.4
|    |    |    \--- io.opencensus:opencensus-contrib-grpc-metrics:0.21.0
|    |    |         \--- io.opencensus:opencensus-api:0.21.0
|    |    +--- com.squareup.okhttp:okhttp:2.5.0 -> 2.7.5
|    |    |    \--- com.squareup.okio:okio:1.6.0 -> 1.13.0
|    |    \--- com.squareup.okio:okio:1.13.0
|    +--- io.grpc:grpc-protobuf-lite:1.21.0
|    |    +--- io.grpc:grpc-api:1.21.0 (*)
|    |    +--- com.google.protobuf:protobuf-lite:3.0.1
|    |    \--- com.google.guava:guava:26.0-android (*)
|    +--- io.grpc:grpc-stub:1.21.0
|    |    \--- io.grpc:grpc-api:1.21.0 (*)
|    +--- io.reactivex.rxjava2:rxandroid:2.0.2
|    |    \--- io.reactivex.rxjava2:rxjava:2.1.9 -> 2.1.14
|    |         \--- org.reactivestreams:reactive-streams:1.0.2
|    \--- io.reactivex.rxjava2:rxjava:2.1.14 (*)
+--- com.google.firebase:firebase-firestore -> 21.4.3
|    +--- androidx.annotation:annotation:1.1.0
|    +--- com.google.android.gms:play-services-base:17.0.0 (*)
|    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    +--- com.google.firebase:firebase-auth-interop:18.0.0
|    |    +--- com.google.android.gms:play-services-base:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-basement:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:17.0.0 (*)
|    |    \--- com.google.firebase:firebase-common:18.0.0 -> 19.3.0 (*)
|    +--- com.google.firebase:firebase-common:19.3.0 (*)
|    +--- com.google.firebase:firebase-components:16.0.0 (*)
|    +--- com.google.firebase:firebase-database-collection:17.0.1
|    |    \--- com.google.android.gms:play-services-base:17.0.0 (*)
|    +--- com.google.firebase:protolite-well-known-types:17.0.0 (*)
|    +--- com.squareup.okhttp:okhttp:2.7.5 (*)
|    +--- io.grpc:grpc-android:1.21.0
|    |    \--- io.grpc:grpc-core:[1.21.0] -> 1.21.0 (*)
|    +--- io.grpc:grpc-okhttp:1.21.0 (*)
|    +--- io.grpc:grpc-protobuf-lite:1.21.0 (*)
|    \--- io.grpc:grpc-stub:1.21.0 (*)
+--- androidx.browser:browser:1.2.0
|    +--- androidx.core:core:1.1.0 -> 1.2.0 (*)
|    +--- androidx.annotation:annotation:1.1.0
|    +--- com.google.guava:listenablefuture:1.0
|    +--- androidx.collection:collection:1.1.0 (*)
|    +--- androidx.concurrent:concurrent-futures:1.0.0
|    |    +--- com.google.guava:listenablefuture:1.0
|    |    \--- androidx.annotation:annotation:1.1.0
|    \--- androidx.interpolator:interpolator:1.0.0 (*)
\--- androidx.work:work-runtime-ktx:2.4.0-alpha03
     +--- androidx.work:work-runtime:[2.4.0-alpha03] -> 2.4.0-alpha03
     |    +--- com.google.guava:listenablefuture:1.0
     |    +--- androidx.lifecycle:lifecycle-livedata:2.1.0 (*)
     |    +--- androidx.room:room-runtime:2.2.5
     |    |    +--- androidx.room:room-common:[2.2.5] -> 2.2.5
     |    |    |    \--- androidx.annotation:annotation:1.1.0
     |    |    +--- androidx.sqlite:sqlite-framework:2.0.1 -> 2.1.0
     |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
     |    |    |    \--- androidx.sqlite:sqlite:[2.1.0] -> 2.1.0
     |    |    |         \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
     |    |    +--- androidx.sqlite:sqlite:2.0.1 -> 2.1.0 (*)
     |    |    \--- androidx.arch.core:core-runtime:2.0.1 -> 2.1.0 (*)
     |    +--- androidx.sqlite:sqlite:2.1.0 (*)
     |    +--- androidx.sqlite:sqlite-framework:2.1.0 (*)
     |    +--- androidx.core:core:1.1.0 -> 1.2.0 (*)
     |    \--- androidx.lifecycle:lifecycle-service:2.1.0
     |         \--- androidx.lifecycle:lifecycle-runtime:2.1.0 (*)
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.71 -> 1.3.72 (*)
     \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4
          +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.70 -> 1.3.72 (*)
          \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4
               +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.70 -> 1.3.72 (*)
               \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.70 -> 1.3.72

dependency_tree.txt

amit12297 commented 4 years ago

Facing the same issue after adding : com.google.firebase:firebase-inappmessaging-display-ktx:19.0.7

Adding this dependency solves the problem, but doesn't look like a good solution: implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

Related links: https://stackoverflow.com/questions/56639529/duplicate-class-com-google-common-util-concurrent-listenablefuture-found-in-modu

davidmotson commented 4 years ago

ah, thank you!

There seems to be a conflict with a library fiam is using and androidx.browser. I'll see if they can address that in their next update.

The link you provided includes some stop gap measures which should allow you to repair your build for now (although let me know if they don't work)

davidmotson commented 4 years ago

Update: This has been fixed in https://github.com/firebase/firebase-android-sdk/pull/1596 and should be in the next FIAM release, I'll post back here once that has gone out.

Thanks gain for bringing this to our attention!

davidmotson commented 4 years ago

Update: Due to some unforseen conflicts that those changes have with other firebase libraries we are delaying this fix so it can be properly tested. I'll post back here as it progresses. For now, anyone seeing this issue should add

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' to their dependencies

amit12297 commented 4 years ago

Okay. Thank you.

ashwinraghav commented 4 years ago

Hey @KonradSzewczuk

The goal of introducing com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava was to allow some androidx libraries to take a dependency on listenable future without taking a dependency on the entirety of guava.

This allows you to have both newer versions of guava and the androidX library (in your case browser) in your classpath without any duplicate class files.

The challenge we are facing is that the version of gRPC that Firebase libs depend on brings in a version of guava that is not new enough. And upgrading gRPC across the board in Firebase SDKs is non trivial https://github.com/firebase/firebase-android-sdk/pull/1534.

We hope to land that change in the coming weeks. Please unblock yourself by including `implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' in your build. While counterintuitive It is safe to continue having depending on it even after you pick up our fixes.

Please track #1152 going forward