react-native-tcp-socket icon indicating copy to clipboard operation
react-native-tcp-socket copied to clipboard

Execution failed for task ':app:checkReleaseDuplicateClasses' for android

Open vr7bd opened this issue 1 year ago • 10 comments

Description

After upgrading to 6.2.0, I'm unable to build my project with this error

Execution failed for task ':app:checkReleaseDuplicateClasses'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable

   > Duplicate class org.bouncycastle.LICENSE found in modules bcprov-jdk15on-1.70.jar -> jetified-bcprov-jdk15on-1.70 (org.bouncycastle:bcprov-jdk15on:1.70) and bcprov-jdk15to18-1.70.jar -> jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70)

I traced it and found out that this occurs if expo-updates is installed and react-native-tcp-socket is on version 6.2.0. It's because of the commit 054c789 where these dependencies are added

    // Bouncy Castle dependencies
    implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
    implementation 'org.bouncycastle:bcpkix-jdk15on:1.70'

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a new expo project and install expo updates
  2. Install the latest version of react-native-tcp-socket
  3. npx expo prebuild && npx expo run:android

vr7bd avatar Jul 28 '24 18:07 vr7bd

Go into your ./android/app/build.gradle and add this in the dependencies block. It will ignore the bad version of bouncycastle.

    implementation(project(':react-native-tcp-socket')) {
        exclude group: 'org.bouncycastle'
    }

regulad avatar Aug 25 '24 16:08 regulad

The same issue!

@regulad how to do your solution for Expo EAS builds?

siarheipashkevich avatar Sep 04 '24 11:09 siarheipashkevich

@vr7bd did you solve this issue?

siarheipashkevich avatar Sep 04 '24 11:09 siarheipashkevich

@vr7bd did you solve this issue?

Not exactly. This works but as pointed out, for EAS builds, this is not a good solution. So I just downgraded to 6.0.1 (if I remember correctly), which is the version prior to the commit of the dependency

vr7bd avatar Sep 08 '24 18:09 vr7bd

This can be solved by a custom Expo config plugin. I have done this for my project. I can open source it.

@vr7bd @siarheipashkevich

ShaneZhengNZ avatar Sep 10 '24 21:09 ShaneZhengNZ

@ShaneZhengNZ please share it if it is possible

siarheipashkevich avatar Sep 11 '24 03:09 siarheipashkevich

@siarheipashkevich sure thing. I should have this done in the next a few days. I will pin you when the package is available to use.

ShaneZhengNZ avatar Sep 11 '24 03:09 ShaneZhengNZ

with-react-native-tcp-socket

@vr7bd @siarheipashkevich

ShaneZhengNZ avatar Sep 12 '24 09:09 ShaneZhengNZ

@ShaneZhengNZ thanks! How do you think is it possible to "patch" this package for avoiding this issue using https://www.npmjs.com/package/patch-package?

siarheipashkevich avatar Sep 12 '24 09:09 siarheipashkevich

I have used yarn patch (similar thing) for patching javascript code or native code before, but never done the build.gradle. Worth a shot I guess?

-- Edit -- In fact, maybe not? The build.gradle file for this repo is possibly ok, but when we build our application, it conflicts with the other package's build.gradle? not sure. I am not an expert about gradle, so don't take my advice.

All I have done is implemented the suggested solution from regulad with Expo Config plugin.

ShaneZhengNZ avatar Sep 12 '24 11:09 ShaneZhengNZ

I just ran across this while making a production build (and installing expo-updates). Very much still a thing, glad I found this topic.

I reverted to 6.0.1 as a solution.

jakobbuis avatar Jan 12 '25 20:01 jakobbuis

Reverting didn't work for me, so I updated the dependency. Made a PR to merge #205.

In the meantime, you can use patch-package to apply the fix as long as the PR isn't merged.

jakobbuis avatar Jan 14 '25 14:01 jakobbuis

:tada: This issue has been resolved in version 6.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Apr 23 '25 21:04 github-actions[bot]