reactnative(0.49以上版本) unable to load script from asset/index.android.bundle問題解決


初學react-native慢慢積累,剛開始就遇到了這個錯誤,找了很多資料解決,在此做下記錄。

  總結:初始化運行紅屏錯誤 unable to load script from asset/index.android.bundle

  原因:assets中沒有成功打包出index.android.bundle文件

  解決:1.去(你的項目文件夾)\android\app\src\main目錄下新建asset文件夾

     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

     3.再次執行 react-native run-android

  注:由於0.49版本以后的react-native沒有index.android.js和index.ios.js文件,而統一合並成了index.js,所以使用0.49及以后版本的同學請將第2步中的入口文件改為index.js

  附上解決方式原貼:https://stackoverflow.com/questions/44446523/unable-to-load-script-from-assets-index-android-bundle-on-windows


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM