我试图在我的设备上第一次运行我的第一个React Native项目(Android 4.2.2)。

我得到:

无法从assets index.android.bundle中加载脚本

我使用的命令:

CD(项目目录) react-native开始 react-native运行android


当前回答

提出一个显而易见的建议,对我很有用。删除应用程序,重新启动服务器,重新从工具部署到设备。

其他回答

就我而言,我忘了Android模拟器的wifi是禁用的。 为了解决这个问题,我只是向下滑动通知栏来展开菜单并启用Wifi连接。

激活Wifi连接后,我的问题就解决了。

提出一个显而易见的建议,对我很有用。删除应用程序,重新启动服务器,重新从工具部署到设备。

此问题也可能是由于设备/模拟器的蜂窝数据被关闭引起的。一定要检查一下。

The most upVoted answer seems working but become hectic for developers to see their minor changes after couple of minutes. I solved this issue by following these steps: 1- Push my code to bitbucket/github repo ( to view the changes later ) 2- cut paste android folder to any safe location for recovery 3- delete the android folder from my project 4- run react-native upgrade 5- Now, I see all the changes between the previous and the lastest build (using VsCode) 6- I found the issue in build.gradle file in these lines of code.

ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}

7-我复制了这些行(由react-native升级脚本生成,并再次删除android文件夹。 8-然后我剪切粘贴android文件夹回到我的项目文件夹,我在第2步剪切粘贴。 9 -替换构建。Gradle文件行与复制的。 10-现在工作正常。

希望这对你有所帮助。

去开发设置->调试服务器主机和端口的设备->输入您的计算机Wifi IP地址(Mac OS:去系统首选项-> Wifi获取Wifi IP地址)

最终重建应用程序并运行