Flipper: Question: Duplicate classes when using flipper alongside react-native

Created on 23 Nov 2019  路  16Comments  路  Source: facebook/flipper

I am using react-native
com.facebook.react:react-native:0.60.5

and flipper version
com.facebook.flipper:flipper:0.28.0
com.facebook.flipper:flipper-network-plugin:0.28.0

I am getting this error

Execution failed for task ':mobile:checkStandardDebugDuplicateClasses'.

1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.facebook.jni.CppException found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.CppSystemErrorException found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread$1 found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread$Destructor found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread$DestructorList found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread$DestructorStack found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.DestructorThread$Terminus found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.HybridClassBase found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.HybridData found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.HybridData$Destructor found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.IteratorHelper found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.MapIteratorHelper found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.NativeRunnable found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.ThreadScopeSupport found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)
Duplicate class com.facebook.jni.UnknownCppException found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)

Go to the documentation to learn how to Fix dependency resolution errors.

I have tried excluding fbJni
exclude group: 'com.facebook.fbjni', module: 'fbjni'

But this doesn't work.

Most helpful comment

Add only this to your build.gradle file

debugImplementation("com.facebook.flipper:flipper:0.30.0") {
      exclude group:'com.facebook.yoga'
      exclude group:'com.facebook.fbjni', module: 'fbjni'
      exclude group:'com.facebook.litho', module: 'litho-annotations'
    }

All 16 comments

Add only this to your build.gradle file

debugImplementation("com.facebook.flipper:flipper:0.30.0") {
      exclude group:'com.facebook.yoga'
      exclude group:'com.facebook.fbjni', module: 'fbjni'
      exclude group:'com.facebook.litho', module: 'litho-annotations'
    }

@deepanshu23 if the above comment solved your issue, would you mind closing it?

Hey @mweststrate, it actually does not really fix the issue.

It will build, but will crash on runtime because of this:
https://github.com/facebook/react-native/issues/27565#issuecomment-567847426

Ok! Would you mind waiting until RN 0.62 is released? In that version we will have standardized the setup and support it first class, so than we should be able to provide more accurate support

Any solution for this? Still appears in 0.62.0.

@tapz Are you sure you're on the latest version of both Flipper and ReactNative?

Yes. Now I'm getting this. Feeling like wasting my time with all this crap.

"Error: Unauthorized request from http://localhost:3000. This may happen because of a conflicting browser extension. Please try to disable it and try again."

And this:

Hermes Debugger Error
Cannot connect to Metro. Please check tat Metro is running and Flipper can connecto to it.

@tapz so the class issue has been solved?

I'll check the Hermes issue tomorrow, as afaik that hasn't been released yet 馃槄. You started the Hermes debugger from the devices plugins in Flipper? For verification, can you list which version of "@react-native-community/cli" is installed in your node_modules?

Hermes Debugger is not under Device plugins. It's under React Native.
CLI: 4.4.0

@tapz opened a PR on the public CLI version for the Hermes Debugger error, thanks for reporting!

Incase people stumble upon this (seems to be the main google result)

The particular error for me was cause by react-native-reactotron, temporarily removing it from my project fixed this.

java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.facebook.jni.CppException found in modules classes.jar (com.facebook.fbjni:fbjni:0.0.2) and classes.jar (com.facebook.react:react-native:0.60.5)

@kyle-ssg Do you manually include anything in your build.gradle for doing this? We currently require some custom exclude rules for every dependency that involves Flipper dependencies in combination with RN.

@passy Nope nothing at all, just autolinking. I believe reactotron has some form of flipper plugin and uses react-native-flipper under the hood so I'm assuming this is why this happens. It's a pretty popular package so I wouldn't be surprised if a lot of people are facing this.

@kyle-ssg you might be right; I'm getting the following error in metro with flipper started (mac)

Error: Unauthorized request from http://localhost:3000. This may happen because of a conflicting browser extension. Please try to disable it and try again. at getSecurityHeadersMiddleware (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/middleware/getSecurityHeadersMiddleware.js:19:10) at call (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:239:7) at next (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:183:5) at Function.handle (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:186:3) at handle (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:91:14) at call (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:239:7) at next (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:183:5) at Function.handle (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:186:3) at Server.app (/Users/calinpastean/Documents/temp-catchcorner/catchcorner/node_modules/connect/index.js:51:37) at Server.emit (events.js:200:13) Error: Unauthorized request from http://localhost:3000. This may happen because of a conflicting browser extension. Please try to disable it and try again.

Any solution for this? Still appears in 0.62.0.

Yes, same issue with me. Is there any solution to solve this ?

I am closing this issue now, as it discusses at least 3 different problems here and it gets terribly confusing.

Please open new issues for any problems still occurring on React Native 0.62.2 and higher, after applying all the changes as introduced by the upgrade helper to your project (for example: https://react-native-community.github.io/upgrade-helper/?from=0.62.0&to=0.62.2).

For android users, please make sure you cleared your cache (gradlew clean in android), and on ios that the pod installations have been installed.

@samapara would you mind opening a fresh issue including your gradle build files?

In general, please report new problems in new issues! Even if they happened two seconds after your previous problem. That makes following up on issues a lot clearer, and makes it also much easier to find the correct solution to the correct problems for others.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings