Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-2

Android添加firebase jar报错如下

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-2

添加依赖

implementation "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"

参考链接 

Duplicate class ListenableFuture after update · Issue #1320 · firebase/firebase-android-sdk · GitHub 

同时可能还会如下错:

More than one file was found with OS independent path 'META-INF/DEPENDENCIES'

 提示 因为多个 jar 包里包含了同样的文件(DEPENDENCIES),导致打包时因为担心相互覆盖问题而提示出错,然而并没有重复:

    packagingOptions {
        pickFirst '**/libc++_shared.so'
        doNotStrip "*/armeabi/libYTCommon.so"
        doNotStrip "*/armeabi-v7a/libYTCommon.so"
        doNotStrip "*/x86/libYTCommon.so"
        doNotStrip "*/arm64-v8a/libYTCommon.so"
    }

在packagingOptions{}中添加  

exclude 'META-INF/DEPENDENCIES'
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        pickFirst '**/libc++_shared.so'
        doNotStrip "*/armeabi/libYTCommon.so"
        doNotStrip "*/armeabi-v7a/libYTCommon.so"
        doNotStrip "*/x86/libYTCommon.so"
        doNotStrip "*/arm64-v8a/libYTCommon.so"
    }

即可解决

猜你喜欢

转载自blog.csdn.net/qq_33721320/article/details/117918954