Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-20.0.jar (com.google.guava:guava:20.0)

后端 未结 8 1621
[愿得一人]
[愿得一人] 2020-12-08 03:58

When I use implementation \'com.google.firebase:firebase-inappmessaging-display:17.2.0\' in my app/build.gradle, I get this error:



        
相关标签:
8条回答
  • 2020-12-08 04:06

    I just came across this when building my Flutter project. Not quite sure why it reared its ugly head, but here I am.

    So, if any Flutter devs come across this, @Ray Li's answer worked for me. The build.gradle file that you want to edit is the one in the android/app folder (ie. NOT the one in the android folder).

    Just add the implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' to the dependencies section at the end of the file, as follows:

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    }
    
    0 讨论(0)
  • 2020-12-08 04:06

    Reduce duplicated dependencies from your project

    For example many dependencies uses support-v4 and appcompat-v7 as included packages and then could be different versions, so you need remove this packages from inside of dependencies and create one compile dependency.

    This will remove all included modules of libraries

    android {
      configurations {
         all*.exclude module: 'appcompat-v7'
         all*.exclude module: 'support-v4'
      }
    }
    

    Or you can manage throw each dependency to more clear removing packages like this:

    dependencies {
      implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0@aar') {//depend on your library
         transitive = true
         exclude group: 'com.android.support', module: 'appcompat-v7'
         exclude group: 'com.android.support', module: 'recyclerview-v7'
         exclude group: 'com.android.support', module: 'design'
         exclude group: 'com.android.support', module: 'support-v4'
         exclude group: 'com.squareup.retrofit2' module: 'retrofit'
         exclude group: 'com.squareup.retrofit2', module: 'retrofit'
         exclude group: 'com.google.code.gson', module: 'gson'
         exclude module: 'guava'//add this line if you have build error "found in modules guava-xxx-android.jar"
      }
    }
    

    All of removed dependencies must be declared outside of mapbox in one copy for all libraries uses them.

    0 讨论(0)
  • 2020-12-08 04:11

    Add this line in build.gradle

        implementation 'com.google.guava:guava:27.0.1-android'
    
    0 讨论(0)
  • 2020-12-08 04:15
    1. Open build.gradle file.

    2. Do Not replace! Just add this line into dependencies{}:

      implementation 'com.google.guava:guava:<version>-jre'
      

    Note: To get the version go to https://mvnrepository.com/artifact/com.google.guava/guava and find for the latest version of jre.

    0 讨论(0)
  • 2020-12-08 04:17

    add this to your gradle file

    configurations {
        all*.exclude group: 'com.google.guava', module: 'listenablefuture'
    }
    
    0 讨论(0)
  • 2020-12-08 04:24

    2020 Solution

    Google knows about this error so they made a special package to fix the conflict.

    Add this to your build.gradle

    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    
    0 讨论(0)
提交回复
热议问题