4

Recently I have formatted my machine and OS been re-installed. Since then when I run react-native run-android old bundle is being installed in my android device.But in emulator updated bundle is loading.

As per this source android OS must be Android 5 and above, But mine is Android 8(Oreo).

Even i tried to do follow these suggestions, But it seems like a work around and have to run those commands every time I update a single character of a code which is not a permanent solution.

As far as i know I must mave missed to do something after reinstalling OS(as it was quite fine before re-installing the OS).

Could any body help to make the new bundle run in device.

ThinkAndCode
  • 1,319
  • 3
  • 29
  • 60

3 Answers3

8

I thing your problem is look like this.

Code is not modified

open you terminal and go to project location and run

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
Ankit Sharma
  • 251
  • 2
  • 9
  • After running this command, If I run `react-native run-android' everything is fine. But may I know what's happening when I run above command? – ThinkAndCode Jan 10 '19 at 05:03
  • This command create a file in android assets and the code compile from that file. If we modify our code and not execute this command then code still execute from that file created before and we are unable to get latest modified changes. – Ankit Sharma Jan 10 '19 at 06:24
  • Running this command creating some new files which i cannot push to my git repo. So every time I push the code i have to delete these files and then have to run the command. Isn't there any permanent solution for this issue with out running the command? – ThinkAndCode Jan 10 '19 at 06:32
  • We have to run command but if you don't want to push that files in your git then you add them to git ignore. – Ankit Sharma Jan 10 '19 at 06:39
  • Ok I will do so, But I am really surprised to see that why it is not working as usual after re-installing the OS. Can you guess any reason? – ThinkAndCode Jan 10 '19 at 06:41
  • This execute your code from existing assets files that does not contain the latest changes. – Ankit Sharma Jan 10 '19 at 06:50
  • May I know reason for executing code from existing assets files? – ThinkAndCode Jan 18 '19 at 08:46
0

Please try this method

  1. First, open your project in the terminal and run 'react-native start'
  2. Open Android studio and run the project on an emulator

If you are stuck with running the application to your device instead of an emulator

  1. Open your project in the terminal and run this, Bundle command

    $sudo react-native bundle --platform android --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --dev false --reset-cache --assets-dest android/app/src/main/res/

  2. Then run react-native start, then open your Android studio and run your application to your device

andrel
  • 1,144
  • 11
  • 25
0

if you are using the git version control system so make sure you have the actual code for the new bundle I mean you are in the actual branch where your code.

try this

simply uninstall the app from the device. Go to the inside android folder then run ./gradlew clean and then cd to root folder and build again using react-native run-android.

Zeeshan Ansari
  • 9,657
  • 3
  • 26
  • 27