尝试在Android 4.4.2上创建一个反应原生项目,我得到了这个错误屏幕

却找不到解决的办法。我尝试重新启动packager,重新连接设备,甚至重新安装react native并开始新的项目。在6.0.0和更高版本上,它工作得很好。


当前回答

我只是简单地中断我正在运行的应用程序,运行npm I,然后再次通过npm start启动应用程序,它工作正常。

其他回答

尝试清理缓存

React-native start -reset-cache

“npm 开始”

我刚刚关闭了终端机,开了一个新的。通过cd命令进入项目位置。然后简单地输入- "npm start"。然后'r'表示重新加载。一切都消失了。我认为每个人都应该马上尝试一下。

如果您正在使用expo,并且正在物理设备上运行它,我建议您关闭metro捆绑包,然后启动expo并尝试它

我也得到了这个错误,真的很困惑。因为不是所有的答案都有效。 就在添加adb到路径之后。

对此,一个可能的解决方案是,您很可能不首先捆绑应用程序,而是执行以下步骤,然后将app-debug.apk部署到您的设备上

$ cd myproject  
$ react-native start > /dev/null 2>&1 &  
$ curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

(如果文件夹资产不存在,创建它)

然后从项目根运行

$> (cd android/ && ./gradlew assembleDebug)

将创建的apk安装到您的设备,地址:android/app/build/outputs/apk/app-debug.apk

如果这解决了你的问题,请告诉我

编辑:

你可以把它放在你的包裹里。我相信它会在即将发布的react-native版本中被修复,并将在组装最终的APK之前执行,因此这将不需要(我希望也是如此)

把:

"scripts": {
    "build": "(cd android/ && ./gradlew assembleDebug)",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "bundle-android": "react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --sourcemap-output android/app/src/main/assets/index.android.map --assets-dest android/app/src/main/res/"
  },

或者如前所述的旋度等效,但对于大多数情况,上面的更健壮