react-native: duplicate entry error related to okhttp3 when integrating React Native into existing Android project
Description
After adding React Native to an existing Android project, I get the following error when running ./gradlew assembleDebug
:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':driver:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
This project already had a dependency on okhttp3, so I’m not sure how to make Gradle ignore the React Native dependency on it.
Additional Information
- React Native version: 0.31
- Platform: Android
- Operating System: MacOS 10.11.6 (15G1217)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 13
- Comments: 18 (12 by maintainers)
I resolved that forcing for all my dependencies would be the same. I had already some dependencies using v3.5.0 and having the conflict with new okhttp-ws integrated into v3.5.0 🤦♂️
It’s a workaround. Be aware that with this one we cannot use v3.5.0.
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
No fix yet. I haven’t had time to investigate further. Like I said above, also not sure if this belongs here or on my Stack Overflow question above.
could you find a fix @lyahdav i’m having exact same issue, but when i use this code
i’m getting another! see this issue
thanks!