我试图在我的设备上第一次运行我的第一个React Native项目(Android 4.2.2)。
我得到:
无法从assets index.android.bundle中加载脚本
我使用的命令:
CD(项目目录) react-native开始 react-native运行android
我试图在我的设备上第一次运行我的第一个React Native项目(Android 4.2.2)。
我得到:
无法从assets index.android.bundle中加载脚本
我使用的命令:
CD(项目目录) react-native开始 react-native运行android
当前回答
当我试图调试我的代码时,我有这个问题(在我的android手机和react开发中使用Toggle检查器),我做了以下简单的步骤:
在手机中打开菜单(在重载的地方,我可以通过长按后退键或摇晃手机来打开它) 在这里输入图像描述 点击“开发设置” 在调试->调试服务器主机和设备端口应该为空 注意:如果你在这里写了port或任何东西(用于调试),你应该清除它。
其他回答
对于这个问题,我只需要运行:
react-native start
then
adb reverse tcp:8081 tcp:8081
在命令行上。然后我可以运行:
react-native run-android
所以我不会浪费时间去跑:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
每一次。
不要忘记在模拟器设备中打开Internet, 我解决了这个错误,它工作完美:V 我得到这个错误,因为我关闭互联网测试NetInfo:D
这是一个常见的错误消息,您可能在react本机应用程序开发过程中遇到过。所以在本教程中,我们将为这个问题提供解决方案。
问题描述: 无法在windows上从assets index.android.bundle中加载脚本 无法在windows上从assets index.android.bundle中加载脚本
按照以下步骤解决上述问题:
步骤1:在项目目录中创建“assets”文件夹 现在在项目目录中创建资产文件夹,名为“MobileApp\android\app\src\main”。您可以手动创建资产文件夹:
<或>
您也可以使用命令创建文件夹。 命令: mkdir android / app / src / main /资产
步骤2:运行React Native应用程序 让我们运行下面的命令在模拟器或物理设备中运行react本机应用程序。
切换到项目目录。 cd MobileApp
运行下面的命令来帮助捆绑你的android应用程序项目。
React-native bundle——platform android——dev false——entry-file index.js——bundle-output android/app/src/main/assets/index.android。Bundle——assets-dest android/app/src/main/res
运行最后一步,在模拟器或物理设备中运行react本机应用程序。 react-native运行android
<或>
您也可以将最后两个命令合并为一个,在这种情况下,您必须只执行一次命令。
React-native bundle——platform android——dev false——entry-file index.js——bundle-output android/app/src/main/assets/index.android。Bundle——assets-dest android/app/src/main/res && react-native run-android
<或>
您可以通过将上述步骤放在包的脚本部分来自动化它们。Json是这样的:
“android-android”:“react-native bundle——platform android——dev false——entry-file index.js——bundle-output android/app/src/main/assets/index.android. js”Bundle——assets-dest android/app/src/main/res && react-native run-android"
如果一切设置正确,您应该很快就会看到新应用程序在Android模拟器中运行。
我面临着这个问题,很多搜索,我解决了这个问题。
c:\ProjectFolder\ProjectName> react-native bundle——platform android——dev false——entry-file index.js——bundle-output android/app/src/main/assets/index.android。Bundle——assets-dest android/app/src/main/res
运行react native:
c: \ ProjectFolder \ ProjectName > react-native运行android
在MAC或Windows上,我们可以在1秒内解决这个问题
在你的项目中搜索project.ext.react这个术语
并在bundleInDebug: true中做一个更改,添加这一行。并再次运行您的项目。
project.ext.react = [
entryFile: "index.js",
enableHermes: true, // clean and rebuild if changing
bundleInDebug: true // **add this line only**
]