Metro server (run ‘react-native start‘) or that your bundle ‘index.android.bundle‘ is packaged corre

React Native 运行或打包时报如下错误:

 java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.

解决办法:

在app/build.gradle添加如下代码
 

project.ext.react = [
    enableHermes: false,  // clean and rebuild if changing
    bundleAssetName:"index.android.bundle",
    bundleInDebug:true,
    bundleInAlpha:true,
    bundleInBeta:true,
]


版权声明:本文为cj_286原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。