React Native搭建报错:Unable to load script

时间:2021-09-15 18:23:43   收藏:0   阅读:24

报错

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.

原因

没有找到index.android.bundle

方法一

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  

方法二

android/app/build.gradle中设置

project.ext.react = [
        bundleAssetName: ‘index.android.bundle‘,
        bundleInDebug: true,
        bundleInAlpha: true,
        bundleInBeta : true
]

主要是设置bundleInDebug等于true,使得开发时也会打包index.android.bundle

原文:https://www.cnblogs.com/allen12/p/15270449.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!