#react-native BUG#

发布时间:2019-06-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了#react-native BUG#脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

这篇文章主要解决react-native中遇到的bug。
环境:window10

Error: Command failed: gradlew.bat installDebug

编译并运行 React Native 应用之前我们可以使用下面的方法清理gradlew 和之前的构建文件。

Error: Command failed: gradlew.bat installDebug
Failed to capture snapshot of output files for task':app:transformClassesWIThDexBuilderForDebug' 
PRoPErty 'streamOutputFolder' during up-to-date check.
Could not read path
'projectandROIdappbuildintermediatestransformsdexBuilderdebug49androidArchlifecycle'.

解决方案

  1. 在项目下运行这面的命令
    在项目目录下输入下面的命令: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
  2. 依次执行下面的命令
cd project/android   //进入当前项目的android文件夹下
gradlew clean
cd ..   //进入当前项目目录
react-native run-android  //编译并运行 React Native 应用

The module ../lib/props could not be found From `projectnode_modulesreact-native-svgelementsRect.js

这个是缓存问题

bundling failed: Error: Unable to resolve module `../lib/props` from `projectnode_modulesreact-native-svgelementsRect.js`: The module `../lib/props` could not be found from `projectnode_modulesreact-native-svgelementsRect.js`.

解决方案

  1. 删除项目中的node_modules文件夹
  2. 重新下载依赖
    执行下面的命令npm install
  3. 清空缓存
    执行下面的命令npm start -- --reset-cache

emulator: ERROR: x86 emulation currently requires hardware acceleration!

场景描述:在react-native 开发的时候,点击AVDManager按钮,出现的报错信息。
解决方法(参考

  1. 在Android Studio中打开SDK Manager并且下载Intel x86 Emulator Accelerator (HAXM installer)。
  2. 进入SDK目录
    目录结构大致这样: C:users%USERNAME%AppDataLocalAndroidsdkextrasintelHardware_Accelerated_Execution_Manager
    执行安装这个文件: intelhaxm-android.exe。
    执行的过程中可能会报错这样的信息:‘Intel virtualization technoLOGy (vt,vt-x) is not enabled’。
    这个问题的解决方法是(参考):

    - Please reboot your System and enter the BIOS SETUP // win10 开机的时候一直按着esc键。    
    - Look for an option labeled "VT", "Intel VT", or "Virtualization"; verify it is enabled. 
    - If VT/Intel VT/Virtualization is disabled, enable the option.   
    - Save the BIOS settings.    
    - Restart the machine.
    - 执行安装这个文件: intelhaxm-android.exe,安装成功。 
  3. 重启Android Studio再次点击 AVDManager应该就不会报错了.

undefined is not an object (evaluating 'RNGestureHandlerModule.State')

yarn add react-native-gesture-handler
react-native link react-native-gesture-handler

settings file 'projectandroidsettings.gradle': 3: unexpected char: '' @ line 3, column 133

new File(rootProject.projectDir, '..node_modulesreact-native-gesture-handlerandroid')
//替换成下面的这个,即在加一个‘’
new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')

Unable to resolve module ./index from react-nativescripts/.

运行下面的命令清除缓存

react-native start -- --cache-reset 

然后在尝试

react-native run-android

Error: listen EADDRINUSE :::8081

//直接根据端口找进程,可以得到一个PID
netstat -ano | findStr "8080"
//Find the process name by pid
tasklist /fi "pid eq 2216"
//杀死进程
taskkill /PID 19856

脚本宝典总结

以上是脚本宝典为你收集整理的#react-native BUG#全部内容,希望文章能够帮你解决#react-native BUG#所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。