这篇文章主要解决react-native中遇到的bug。
环境:window10java
编译并运行 React Native 应用以前咱们可使用下面的方法清理gradlew 和以前的构建文件。node
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 'project\android\app\build\intermediates\transforms\dexBuilder\debug\49\android\arch\lifecycle'.
解决方案:react
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
cd project/android //进入当前项目的android文件夹下 gradlew clean cd .. //进入当前项目目录 react-native run-android //编译并运行 React Native 应用
../lib/props
could not be found from `projectnode_modulesreact-native-svgelementsRect.js这个是缓存问题android
bundling failed: Error: Unable to resolve module `../lib/props` from `project\node_modules\react-native-svg\elements\Rect.js`: The module `../lib/props` could not be found from `project\node_modules\react-native-svg\elements\Rect.js`.
解决方案ios
npm install
npm start -- --reset-cache
场景描述:在react-native 开发的时候,点击AVDManager按钮,出现的报错信息。
解决方法(参考)git
进入SDK目录
目录结构大体这样: C:users%USERNAME%AppDataLocalAndroidsdkextrasintelHardware_Accelerated_Execution_Manager
执行安装这个文件: intelhaxm-android.exe。
执行的过程当中可能会报错这样的信息:‘Intel virtualization technology (vt,vt-x) is not enabled’。
这个问题的解决方法是(参考):github
- 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,安装成功。
yarn add react-native-gesture-handler react-native link react-native-gesture-handler
new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android') //替换成下面的这个,即在加一个‘\’ new File(rootProject.projectDir, '..\\node_modules\\react-native-gesture-handler\\android')
./index
from react-native\scripts/.
运行下面的命令清除缓存npm
react-native start -- --cache-reset
而后在尝试react-native
react-native run-android
//直接根据端口找进程,能够获得一个PID netstat -ano | findStr "8080" //Find the process name by pid tasklist /fi "pid eq 2216" //杀死进程 taskkill /PID 19856
在写react项目的时候剩余运算符解析报错。解决方案:
解构对象须要用到 stage-3 的 preset。缓存
//安装stage-3 npm install --save-dev @babel/preset-stage-3 //配置 { "presets": ["stage-3"] }
到这里从新运行项目可能会遇到这样的bug信息:
Error: Couldn't find preset "stage-3" relative to directory
这时咱们能够尝试安装
npm install --save-dev babel-preset-stage-2
在运行项目应该就能够了!
解决的方法除了只有先老老实实从手机上卸载原有版本再进行安装,而adb install -r参数也没法解决这个问题
问题描述:
执行 react-native run-android后,报错:
解决方法:
把手机上以前安装的应用程序删除,执行
$ adb forward --remove-all $ adb forward tcp:8082 tcp:8082 react-native run-android
摇动手机反应很差,咱们能够执行下面的命令,跳出选择项
$ adb sell input keyevent 82
RESPONDER_INACTIVE_PRESS_IN
to RESPONDER_ACTIVE_LONG_PRESS_IN
, which is not supported.参考: https://github.com/facebook/r...
I 'fixed' this by manually setting the device time in Android. Make sure the new time will equal that of your computer (aim for the next minute change), confirm the time change on the very same second your computer time will change to the next minute.
方法:让PC和phone时间一致,尽可能同时让二者同时进入下一分钟。
BUG描述:在scrollView组件中有TextInput组件,当手指聚焦到输入框中时,手指上滑或者下滑,输入框中的placeholder内容消失,且页面不滑动。
解决办法:
给TextInput 添加属性multiline={Platform.OS !== 'ios'}
官网解释是:
若是为true,文本框中能够输入多行文字。默认值为false。注意安卓上若是设置multiline = {true},文本默认会垂直居中,可设置textAlignVertical: 'top'样式来使其居顶显示。
BUG描述:用苹果电脑开发的项目,打包在win10系统下打开执行下面命令就这样了
`npm install
react-native run-android`
解决办法:
https://blog.csdn.net/fxp850899969/article/details/78229758
端口被占用解决方案:`netstat -ano|findstr "8081" # 找到占用8080端口的进程,得到它的PIDkill 12345 # 经过PID杀死该进程`