我正在尝试使用 Windows 7 和 Android 设备使用 React Native 启动我的 hello world 应用程序。还有类似的问题here但我没能成功。
到目前为止我运行的命令设置并导致了这个问题。
- 创建应用:
react-native init helloMe
- 移至根目录 [helloMe]。
react-native run-android
- Android 设备设置正常并使用 adb 在 CMD 中显示
- 打开另一个 CMD 窗口然后运行:
react-native start
- 再次运行
react-native run-android
。 - 手机上显示红屏,此错误无法 load script from assets index.android.bundle on windows
尝试使用步骤 6 中的解决方案修复它会导致另一个错误,这就是我来这里的原因。下面是我的 CMD 日志。
E:\testdir\react_ws\helloMe>react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res Scanning 558 folders for symlinks in E:\testdir\react_ws\helloMe\node_modules (30ms) Scanning 558 folders for symlinks in E:\testdir\react_ws\helloMe\node_modules (20ms) Loading dependency graph, done. Cannot find entry file index.android.js in any of the roots: ["E:\\testdir\\react_ws\\helloMe"] E:\testdir\react_ws\helloMe>
现在,当我尝试使用上述解决方案解决问题时出现另一个错误。
Cannot find entry file index.android.js in any of the roots: ["E:\\testdir
\\react_ws\\helloMe"]
如果尝试应用来自 here 的此修复程序
npm run start -- --root <directory_with_your_react_component_js_sources>
因为我在项目根目录下运行命令,所以我改为运行这个
npm run start -- --root ./
但它不起作用。
这是我的根项目结构
__tests__ app.json index.ios.js node_modules yarn.lock
android index.android.js ios package.json
我希望我清楚,任何帮助将不胜感激。设备卡在红色屏幕上并显示 404。
React-native-version
react-native-cli: 2.0.1
react-native: 0.46.0
最佳答案
将 React 项目的版本从 here 更改为较低版本
npm install -g rninit
rninit init [Project Name] --source react-native@0.40.0
在 .如果您得到 错误 Could not get BatchedBridge。运行这个
adb reverse tcp:8081 tcp:8081
这对我有用。
关于react-native - 在任何根目录中都找不到入口文件 index.android.js :[ Android ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944194/