React-Native 学习问题

1.ERROR  Packager can't listen on port 8081:这个问题是因为你已经有一个命令行程序正在运行!

2.Could not connect to development server : 打开新的命令行窗口 运行 react-native start

3.* What went wrong:

Execution failedfortask':app:installDebug'.> com.android.builder.testing.api.DeviceException: No connected devices!

*Try:

Runwith--stacktraceoptiontogetthe stack trace. Runwith--infoor--debugoptiontogetmore log output.

BUILD FAILED 这是设备没启动起来 推荐使用genymotion模拟器

4.导入的类必须是大写的   import App from ‘./src/app’;正确    import app from ‘./src/app’;错误.

5.当从github新download下来一个项目,并运行react-native run-ios命令时,报React Native: Command run-ios unrecognized

    1.第一步:npm install –save react-native@latest

     2.第二步:npm install

6.  .invariant violation:expected a component class,got[object object]           创建自定义组件首字母要大写,否则会报错.

7.  .Module 0 is not a registered callable module.将gradle升级成最新版本(cdAndroid 进入android目录执行:sudo./gradlew clean) 或者通android        studio工具升级.

8..android.view.WindowManager$BadTokenException: Unable to add window – token null is not valid; is your activity running?

该错误属于安卓Native的错误,如果引用的Activity不存在或者已经销毁,再次引用就会报该错误,如果是React Native 调用原生控件的话,创建控件需要引用:getCurrentActivity()

9.  .react native undefined is not an object (evaluating this….

发生该错误的一般是忘记bind(this),只要回调函数中需要用到this的,一般都需要bind.

10.react native 错误unable to load script form assets解决

      1.首先手动在main下建立一个assets文件夹

     2.然后cmd 进入项目的根目录下执行react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

     3.在执行react-native run-android 跑起来了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,357评论 25 708
  • React Native嵌入Android原生项目中 开发环境准备 首先你要搭建好React Native for...
    呼呼哥阅读 653评论 3 1
  • 作为一名Android开发,学习React Native其实是一个很陡峭的过程,本文主要记录自己从接触React ...
    stefanli阅读 2,664评论 2 15
  • 我去过的地方不多,其中印象比较深刻的是哈尔滨的中央大街。 中央大街的繁华,也没有办法掩盖我的孤独。没有朋友的陪伴,...
    镒na阅读 304评论 0 0
  • 我总希冀着我能抛下些东西,为了你 抛下一些无关的和紧要的 装作一场私奔可我不能你不像是能让我放心腾空一些东西的人因...
    chiyc199402阅读 147评论 0 0