2

I follow all instructions for installing React Navigation for Android.

First, "npm install --save react-navigation", " npm install --save react-native-gesture-handler". "react-native link react-native-gesture-handler" and lastly, updated my MainActivity.java

Here is my MainActivity.java:

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

/**
 * Returns the name of the main component registered from JavaScript.
 * This is used to schedule rendering of the component.
 */
@Override
protected String getMainComponentName() {
    return "InstagramClone";
}

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
  @Override
  protected ReactRootView createRootView() {
   return new RNGestureHandlerEnabledRootView(MainActivity.this)
  }
};
}
}

This is the error I got:

  • What went wrong: Failed to create parent directory 'D:\React Native Projects\InstagramClone\node_modules\react-native-gesture-handler\android\build' when creating directory 'D:\React Native Projects\InstagramClone\node_modules\react-native-gesture-handler\android\build\intermediates\check-manifest\debug'
2
  • try to remove whitespaces in your directory: 'D:\React Native Projects\InstagramClone\ => 'D:\ReactNativeProjects\InstagramClone\ Commented Dec 30, 2018 at 14:43
  • 1
    Did you find the solution? I'm facing the same problem Commented Jan 11, 2019 at 11:47

3 Answers 3

1

If you initiated your project with expo just install react-native-gesture-handler. But if your projected started by react-native cli you have to first install react-native-gesture-handler and then link it to all packages by the command:

react-native link
Sign up to request clarification or add additional context in comments.

Comments

0

if you had to a link react-native-gesture-handler there should be no problem or you try react-native link it will be link all package. Or if you still face same problem delete app first on your emulator then React-native run-android again

Comments

0

You need to install react-native-gesture-handler npm separately. They create separated npm package for touch & gesture handling and recognition.

Step 1.

npm i react-native-gesture-handler 

Step 2.

react-native link react-native-gesture-handler 

Step 3.(optional )

If step 2 is not worked properly, code is not configured properly so we are manually configure it using step 3

To finalize the installation of react-native-gesture-handler for Android, be sure to make the necessary modifications to MainActivity.java:

import com.facebook.react.ReactActivity;  import com.facebook.react.ReactActivityDelegate;  import com.facebook.react.ReactRootView;  import
 com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity { 
@Override protected
 String getMainComponentName() { return "Example"; } 

@Override 
protected ReactActivityDelegate createReactActivityDelegate() { 
return new ReactActivityDelegate(this, getMainComponentName()) { 

@Override 
protected ReactRootView createRootView() { 
return new RNGestureHandlerEnabledRootView(MainActivity.this);  } 
 }; 
 } }

No additional steps are required for iOS.

Please Refer the following document for more information:-

https://reactnavigation.org/docs/en/getting-started.html#installation

https://www.npmjs.com/package/react-native-gesture-handler/v/1.0.0-alpha.34?activeTab=readme

https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.