当前位置: 首页 > 知识库问答 >
问题:

无法从资产“index.android.bundle”加载脚本。请确保包已正确打包或正在运行打包服务器

桓嘉谊
2023-03-14

我正在使用版本为0.38.0的React本机应用程序,当我试图将其升级到0.45.1时,它显示以下错误

java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
at com.facebook.react.cxxbridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:198)
at com.facebook.react.cxxbridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:33)
at com.facebook.react.cxxbridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:216)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:994)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:746)
at java.lang.Thread.run(Thread.java:761)

我尝试过以下的解决方案,但对我来说并不奏效

SO:无法在Windows上从assets index.android.bundle加载脚本
SO:react native android无法加载JS bundle

共有1个答案

东门子昂
2023-03-14

1-创建新文件夹=>android/app/src/main/assets
2-运行此命令=>

 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  

此命令将创建2个文件:index.android.bundle&index.android.bundle.meta

3-运行命令=>react-native run-android

 类似资料: