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

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


当前回答

我也遇到过这个问题。 我所做的就是强制关闭我设备上的应用,然后打开另一个控制台并运行

react-native start

然后我从设备上再次打开应用程序,它又开始工作了。

编辑:如果你通过USB使用android设备,并且拔掉了USB插头,或者你的电脑处于休眠状态,你可能需要先运行

adb reverse tcp:8081 tcp:8081

其他回答

刚刚得到这个错误。以下是我所做的调整: 我选择解散,进入开发人员菜单,然后是开发人员设置, 为设备选择调试服务器主机和端口,我添加了我的计算机的IP地址和端口:192.168.0。* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *。端口通常为:8081

一旦我这样做了,一切都很顺利。此外,当你在开发菜单中,记得选择启用Live Reload和Debug JS远程,它会让你的调试工作更加容易。

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

当我们开始react native项目#1时,大多数人都是第一次面对这个问题。

几个简单的步骤解决了我的问题:

我使用命令创建了一个示例项目:

react-native init ReactProject1

解决方案

修复是帮助local-cli\runAndroid\adb.js找到adb.exe,方法与local-cli\runAndroid\runAndroid.js相同:

\node_modules\react-native\local-cli\runAndroid . find replace statement under projectname(不管你给了什么

替换:

const devicesResult = child_process.execSync('adb devices');

By:

const devicesResult = child_process.execSync( (process.env.ANDROID_HOME ? process.env.ANDROID_HOME + '/platform-tools/' : '') + 'adb devices');

在完成上述替换后,只需在cmd中运行react-native run-android,它将捆绑apk,并首先尝试在您的设备中本地安装js bundle。(成功了)

我的问题是,我通过我的AndroidManifest.xml文件,并删除了行

< uses-permission android: name = " android.permission。互联网" / >

因为我的应用程序不需要网络。然而,react本机调试应用程序确实需要互联网访问(访问packager)。:)

因为你使用的是Android < 5.0,所以你不能使用默认的adb反向方法,但是Facebook已经添加了官方文档来通过Wi-Fi连接到开发服务器,这将支持你的版本。引用MacOS的说明,但也有Linux和Windows的说明:

Method 2: Connect via Wi-Fi You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding. You can find the IP address in System Preferences → Network. Make sure your laptop and your phone are on the same Wi-Fi network. Open your React Native app on your device. You'll see a red screen with an error. This is OK. The following steps will fix that. Open the in-app Developer menu. Go to Dev Settings → Debug server host for device. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). Go back to the Developer menu and select Reload JS.