How to resoleve unable to load script from assets 'index.android bundle' ,make sure your bundle is packaged correctly or youu're runing a packager server

cover from :
        http://blog.csdn.net/u014175342/article/details/73823904

在android模擬器上運(yùn)行react-native項(xiàng)目時(shí)

報(bào)錯(cuò):unable to load script from assets 'index.android bundle' ,make sure your bundle is packaged correctly or youu're runing a packager server

解決方案:
第一步:在 android/app/src/main 目錄下創(chuàng)建一個(gè) assets空文件夾
第二步:執(zhí)行 下面這段命令

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/ 

會(huì)發(fā)現(xiàn) assets文件夾下多出兩個(gè)文件
第三步:重新執(zhí)行react-native run-android 程序跑起來(lái)了。

總結(jié):
這個(gè)index.android.bundle毫無(wú)疑問(wèn)就是用來(lái)調(diào)用原生控件的js腳本,每次當(dāng)你改變了 index.android.js,你都需要使用上面的代碼片段,來(lái)及時(shí)的更新index.android.bundle,然后打包才可以把新的index.android.js應(yīng)用上,所以當(dāng)沒(méi)有index.android.bundle文件時(shí),RN是無(wú)法運(yùn)行的.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容