8

I'm currently having this error when I build my react native project using android studio. How do I fix this and remove the duplicates.

 Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
    Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfo found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
    Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfoEntry found in modules imagepipeline-base-2.2.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.2.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
forests
  • 345
  • 5
  • 11

3 Answers3

7

This seems to be caused by conflicts between Flipper and Fresco. Add this to the app level build.gradle:

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.fbjni'
    exclude group:'com.facebook.fresco'
}

(FLIPPER_VERSION is defined in gradle.properties as 0.33.1)

Thijs
  • 587
  • 5
  • 16
7

I had a similar error when I upgraded my React Native project to 0.68.2.

Solved this by updating the Flipper SDK version. The flipper version was 0.33.1 and changed it to 0.99.0.

Credits

Mahendra Liya
  • 12,912
  • 14
  • 88
  • 114
4

I had the same error. Removing the following code from package.json the dependencies worked for me:

"react-native-photo-view": "github:shoutem/react-native-photo-view#0ffa1481f6b6cb8663cb291b7db1d6644440584d"

I'm not really sure why but maybe because that's where the duplication is.