react-native开发过程中踩过的坑

0、Could not install the app on the device, read the error above for details.

jax$  react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...

Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

jax$ adb devices
List of devices attached
192.168.56.101:5555 device

解决方案:
首先,你应该检查你android/gradlew的权限,应该是755而不是644,然后在你的根目录执行:
{% codeblock %}
chmod 755 android/gradlew
{% endcodeblock %}

1、当把RN项目从一个目录移动到另一个目录时,run-ios时可能会出现异常:

error: PCH was compiled with module cache path 

解决方案:在项目根目录下执行

rm -rf ios/build/ModuleCache/*

然后再react-native run-ios,搞定。

2、当react-native unlink xxxx某些模块是,会出现search.filter not a function的异常,

解决方案:
找到ios/项目名.xcodeproj/project.pbxproj,并用webstorm等非xocde编译器打开,然后全局搜索"$(inherited)"
将其替换成("$(inherited)")。注意:是当前search path下只存在"$(inherited)"一个的情况下。

3、RN版本0.45以后经常会出现一些third-party的问题,比如:third-party: 'config.h' file not found

解决方案:

  • 在项目根目录下执行:(不一定是这个路径,具体看third-party下的glog版本)
cd node_modules/react-native/third-party/glog-0.3.4
  • 执行
../../scripts/ios-configure-glog.sh
  • Glog配置完成,xcode也会找到config.h头文件了。
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 亲爱的自己,今天已经是你写心赏的第47天了,真想不到你能坚持这么多天用心去发现你自己、老公、大宝二宝等一家人的优点...
    大宝二宝一家人阅读 97评论 0 0
  • 赢和输是不能量化的,它们只是一种心境。只有认输,你才会输。 赢意味着到达了你真正选择的目的地。从根本上说,赢的意义...
    陈诚chen阅读 558评论 0 0