How to use offline bundle on android for react native project?

For offline bunduling of JS into android, first start the server in respective project path:

  1. when server start, open next terminal with same path as project path
  2. copy and paste this command:
    Before you copy and paste command in command propmt, make assets folder in project respective path
    as:
    android/app/src/main/assets

    paste this command in command prompt and run:

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/
  1. Then in assets folder there will appear file as index.android.bundle
  2. Finally, run command: react-native run-android(while building new offline apk you need not to start server, your offline js file will help you to build apk file.)
  3. Final, apk now build is ready for running in different devices(run apk from app/src/build/debug.apk).
  4. Sometimes newly made apk will run without showing images, If application runs without image , then copy and paste the specific image resource folder into android/app/src/main/assets/(image source folder)
  5. Again rerun application and thus build apk is ready for running.

Leave a Comment