Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 每次我安装react navigation时,我的项目都会停止工作_Android_Reactjs_React Native - Fatal编程技术网

Android 每次我安装react navigation时,我的项目都会停止工作

Android 每次我安装react navigation时,我的项目都会停止工作,android,reactjs,react-native,Android,Reactjs,React Native,我正在尝试在我的react原生项目中使用react导航。在我安装react navigation之前,该项目将一直运行。当我尝试使用虚拟设备运行我的应用程序时,安装了它之后,当我尝试使用命令react native run android时,我不断收到一个错误 我不确定发生了什么,但在安装react navigation之前,它工作正常。下面是我尝试启动它后遇到的错误 对MainActivity.java进行以下修改: package com.reactnavigation.example;

我正在尝试在我的react原生项目中使用react导航。在我安装react navigation之前,该项目将一直运行。当我尝试使用虚拟设备运行我的应用程序时,安装了它之后,当我尝试使用命令react native run android时,我不断收到一个错误

我不确定发生了什么,但在安装react navigation之前,它工作正常。下面是我尝试启动它后遇到的错误


对MainActivity.java进行以下修改:

package com.reactnavigation.example;

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);
      }
    };
  }
}
然后在条目文件的顶部添加以下内容,例如index.js或App.js:

import 'react-native-gesture-handler';

对MainActivity.java进行以下修改:

package com.reactnavigation.example;

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);
      }
    };
  }
}
然后在条目文件的顶部添加以下内容,例如index.js或App.js:

import 'react-native-gesture-handler';

根据“EPERM”判断,此错误表明您无权执行此操作。 如果您已经按照文档页面上的指南进行了操作,并且已经确认您已经添加了Anish编写的答案中的行(我在代码行中编辑了“+”),那么您应该能够使用依赖项。 如果错误仍然出现,请检查项目的创建位置(检查您是否有写入该文件夹的权限)并检查代码。我想指出的是,在最新版本中,react navigation将其依赖项分散在多个包中(例如,有一个用于堆栈导航器,一个用于选项卡导航器等等)。另外,请确保安装名为
react native reanimated react native手势处理程序react native screens react native safe area context
的软件包

您还应该尝试使用
npm cache clean--force
清理缓存和
npm install-gnpm@latest--强制
以管理员身份全局安装最新的npm

根据“EPERM”判断,此错误表明您无权执行此操作。 如果您已经按照文档页面上的指南进行了操作,并且已经确认您已经添加了Anish编写的答案中的行(我在代码行中编辑了“+”),那么您应该能够使用依赖项。 如果错误仍然出现,请检查项目的创建位置(检查您是否有写入该文件夹的权限)并检查代码。我想指出的是,在最新版本中,react navigation将其依赖项分散在多个包中(例如,有一个用于堆栈导航器,一个用于选项卡导航器等等)。另外,请确保安装名为
react native reanimated react native手势处理程序react native screens react native safe area context
的软件包

您还应该尝试使用
npm cache clean--force
清理缓存和
npm install-gnpm@latest--强制
以管理员身份全局安装最新的npm