为编程爱好者分享易语言教程源码的资源网
好用的代理IP,游戏必备 ____广告位招租____ 服务器99/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器
好用的代理IP,游戏必备 ____广告位招租____ 服务器低至38/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器

网站首页 > 网络编程 > html 正文

react-native navigation安装适配

访客 2020-12-18 12:59:55 html 988 ℃ 1 评论

win10系统vscode 安装 react-navigation。从网上看了好多,大部分都说的不全,或者是苹果系统,搞了好多天终于找到完整的操作。
任何一个依赖没安装,都会安装app失败,报错如图。出现类似报错尽量不要百度,给的答案都太老,没一个有用的。据说ios 不用这么麻烦,但是没苹果本,只能受这个罪

The development server returned response error code:500
解决方案:重新安装依赖,重新配置。

微信图片_20201218131627.jpg


  1. 安装主库
    yarn add react-navigation



  2. 安装主库依赖的第三方库
    yarn add react-native-gesture-handler
    yarn add react-native-reanimated
    yarn add react-native-safe-area-context
    yarn add @react-native-community/masked-view
    yarn add react-native-screens
  3. 引入导航组件的库
    
    yarn add react-navigation-stack
    yarn add react-navigation-drawer
    yarn add react-navigation-tabs
  4. 为 react-native-screens 添加依赖
    用vscode 打开项目,在 android/app/build.gradle 文件中搜 implemetation (ctil+f),因为这个代码较多,在下面部分,直接搜。添加如下:
    
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
  5. 配置 react-native-gesture-handle
    路径:android>app>src>main>java>MainActivity.java
    
    修改1:头部导入
    import com.facebook.react.ReactActivityDelegate;
    import com.facebook.react.ReactRootView;
    import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
    
    修改2:Mainactive底部增加(不是替换,是增加一个新的):
       @Override
      protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
          @Override
          protected ReactRootView createRootView() {
           return new RNGestureHandlerEnabledRootView(MainActivity.this);
          }
        };
    }
  6. 在 index.js 中 导入 react-native-gesture-handler
    
    import "react-native-gesture-handler"




  7. 如果需要安装icon的话
    安装icon :yarn add react-native-vector-icons
    
    在目录文件 android/app/src/build.gradle  
    添加apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
    
    参考:
    https://github.com/oblador/react-native-vector-icons
    https://oblador.github.io/react-native-vector-icons/

来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:21414575

已有1位网友发表了看法:

  • 访客

    访客  评论于 [2020-12-21 10:23:00]  回复

    原来如此

欢迎 发表评论:

百度站内搜索
关注微信公众号
三叶资源网⑤群:三叶资源网⑤群

网站分类
随机tag
图像二值化键盘敲音乐APlayer模块源码精易模块sign算法代理注册辣妈帮标签单据编辑器采集网页图片源码自动发货易语言游戏开发QQ达人web微信源码Safengine数据结构临时会话短网址接口bitmap进制转换内存
最新评论