Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate dependencies during gradle build. #269

Merged
merged 4 commits into from
May 21, 2024

Conversation

filip131311
Copy link
Collaborator

@filip131311 filip131311 commented May 16, 2024

Description:
some 3rd party libraries, could cause duplication of classes during transformation we performed in configureReactNativeOverrides.

This is a solution for RN versions 74 and higher that relays on the fact that we don't need to perform configureReactNativeOverrides for those versions, because the solution were marged upstream.
see: facebook/react-native#42617

How to reproduce a bug?

  • run npx react-native init your-project
  • run npm i react-native-biometrics
  • try to run react-native-ide on android

note that react-native-ide will believe that it is not a native change so it you will have to manually clean rebuild every time you add or remove react-native-biometrics.

This is the reported error in build logs:
Screenshot 2024-05-13 at 02 38 41

Copy link

vercel bot commented May 16, 2024

Someone is attempting to deploy this pull request to the software-mansion Team on Vercel.

To accomplish this, the commit author's email address needs to be associated with a GitHub account.

Learn more about how to change the commit author information.

@filip131311 filip131311 requested a review from kmagiera May 16, 2024 12:45
@filip131311 filip131311 changed the title Fix duplicate dependencies during gradle build. Fix duplicate dependencies during gradle build. [wip] May 16, 2024
Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have fixed this issue I was experiencing on RN 74 dev client builds

@filip131311 filip131311 changed the title Fix duplicate dependencies during gradle build. [wip] Fix duplicate dependencies during gradle build. May 20, 2024
@filip131311 filip131311 requested a review from kmagiera May 20, 2024 17:38
Comment on lines 8 to 19
const workspacePath = getAppRootFolder();
const packageJsonPath = path.join(workspacePath, "package.json");

try {
const jsonString = await fs.promises.readFile(packageJsonPath, "utf8");
const packageJson = JSON.parse(jsonString);
return semver.valid(semver.coerce(packageJson!.dependencies["react-native"])) ?? "0.74.0";
} catch (err) {
Logger.debug("Error:", err);
}

return "0.74.0";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the technique where we check installed react-native and not what's in the package.json. It could be that lower version is specified with ^ and 0.74 could be installed in that case.

We should use this technique: https://github.com/software-mansion/react-native-ide/blob/main/packages/vscode-extension/src/project/metro.ts#L102 to locate react-native in node modules, then extract version field from package.json under that folder. This should give us an explicit version number instead of some pattern. Also, you can use require to load JSON files instead of using fs

@filip131311 filip131311 requested a review from kmagiera May 21, 2024 10:24
@kmagiera kmagiera merged commit 464ffa3 into main May 21, 2024
1 of 2 checks passed
@kmagiera kmagiera deleted the @Filip131311/FixDuplicateDependencyies branch May 21, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants