Skip to content

How to consume changed/forked RN-GH? (Android Package Name Problem) #1250

Closed

Description

@creambyemute

Description

Hey there,
Following situation: I'm currently reinitialising our react-native-windows app and have to make a few changes to RNGH in order for it (and react-navigation) to work on RN-Windows (see #1081).

So I forked the repository, changed the mentioned files and commited. Then I consume the forked git repository from github and it works fine on Windows.

If I try to build the android app, the gradle build aborts with PackageList.java:15: error: cannot find symbol import com.swmansion.gesturehandler.RNGestureHandlerPackage; because the .react after .gesturehandler is missing in the auto-generated PackageList.

Code

No code needed.

Repro steps:

  • Fork repository (or directly consume the github repo)
  • Init project and add the forked gesture-handler
  • Try to build android

Package versions

RN: 0.63.4
RN-GH: 1.9.0

Activity

  1. creambyemute commented on Dec 1, 2020

    @creambyemute
    Author

    I was able to resolve this by switching back to consuming the official release and adding a postinstall script (as mentioned in #1081).

    You can create yourself a script at project root, mine is called webToWindowsRNGH.js:

    const fs = require("fs");
    
    function callback(err) {
        if (err) {
            throw err;
        }
        console.log("Successfull!");
    }
    
    [
        "./node_modules/react-native-gesture-handler/GestureHandlerButton.web.js",
        "./node_modules/react-native-gesture-handler/PlatformConstants.web.js",
        "./node_modules/react-native-gesture-handler/RNGestureHandlerModule.web.js"
    ].forEach((inputPath) => {
        const splits = inputPath.split("./node_modules/react-native-gesture-handler/");
        const newFileName = splits[1].replace(".web.js", ".windows.js");
        const outputPath = "./node_modules/react-native-gesture-handler/" + newFileName;
    
        console.log(`Trying to copy ${inputPath} to ${outputPath}`);
        fs.copyFile(inputPath, outputPath, callback);
    });

    After that, adapt the package.json and add the postinstall script:
    "postinstall": "node ./webToWindowsRNGH"

  2. jgonet commented on Dec 1, 2020

    @jgonet
    Member

    You can also edit files directly in node_modules and use patch-package to apply those changes after npm / yarn install.

  3. creambyemute commented on Dec 1, 2020

    @creambyemute
    Author

    @jakub-gonet I guess that'd be the appropriate way if I'd also edit the files content, but here I just needed to duplicate the .web.js version with .windows.js as file ending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions