【问题标题】:Cannot find entry file index.android.js in any of the roots:[ Android ]在任何根目录中都找不到入口文件 index.android.js:[ Android ]
【发布时间】:2017-12-10 04:23:17
【问题描述】:

我正在尝试使用 Windows 7 和 android 设备使用 react native 启动我的 hello world 应用程序。有一个类似的问题here,但我没能让它工作。

到目前为止我运行的命令来设置并导致此问题。

  1. 创建应用程序:react-native init helloMe
  2. 已移至根目录 [helloMe]。 react-native run-android
  3. Android 设备设置正常并使用 adb 在 CMD 中显示
  4. 打开另一个 CMD 窗口然后运行:react-native start
  5. 又跑react-native run-android了。
  6. 手机显示红屏,此错误无法load script from assets index.android.bundle on windows
  7. 尝试使用步骤 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-cli: 2.0.1
react-native: 0.46.0

谢谢。

【问题讨论】:

  • 分享你的 react native 项目骨架
  • 您好,您要截图吗?因为我没有改变基本应用程序的任何内容
  • tests_ app.json index.ios.js node_modules yarn.lock android index.android.js ios package.jso
  • 是的,我需要截图
  • 我已添加图片

标签: react-native


【解决方案1】:

将react项目的版本从here更改为较低的版本

npm install -g rninit

rninit init [Project Name] --source react-native@0.40.0

在 iOS 和 Android 上都可以正常工作。如果您收到错误,无法获取 BatchedBridge。运行这个

adb reverse tcp:8081 tcp:8081

这对我有用。

【讨论】:

    【解决方案2】:

    1:在 cmd 中使用此命令 ipconfig 查找您的 ip
    并把它放在Dev Sttings => Debug server host&amp; port for device

    2:打开设备wifi

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多