facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.18k stars 24.21k forks source link

react-native run-android do not updating modified code. #9977

Closed Anuj-786 closed 7 years ago

Anuj-786 commented 7 years ago

hey guys ! i have a problem with building the app when i run my app with react-native run-android it build successfully and install the app on emulator but does nor reflect the changes, it shows me the output of of default welcome page which comes on first run when we created the app.

st0ffern commented 7 years ago

have you tried react-native start --reset-cache ?

Anuj-786 commented 7 years ago

@stoffern I tried this but my issues is not with this it works me fine. i want to create final apk by react-native run-android and want to install on another physical device not on emulator.

st0ffern commented 7 years ago

@Anuj-786 i dont quite understand what you are saying. If you want to generate a signed APK then follow this: https://facebook.github.io/react-native/docs/signed-apk-android.html if you want to deploy it to device and debug it on the computer follow this: https://facebook.github.io/react-native/docs/running-on-device-android.html

Anuj-786 commented 7 years ago

thanks, @stoffern the problem was not properly finished but now i am able to run my app that you mentioned the link for adb devices. It works me fine thank you man.

hhsadiq commented 7 years ago

I am having the same issue. The react-native is unable to detect any change for ios as well as android. I am using iginte boilerplate. Cleaned the project multiple times, deleted cache, re-built things, but looks like JS code is even compiled. Because when I took out whole JS code directory, the build still succeeded.

hongsa commented 7 years ago

I am having the same issue. How can I solve this issue?? Only pre version is build in real device. On virtual device(Genymotion), this problem is not ocurred.

mistypix commented 7 years ago

everytime i make some change to app.js file, i have to rebuild the project again with npm start. why are the changes not appearing automatically when i save ? or is this the way it is supposed to be?

vanskins commented 7 years ago

I'm also facing this issue :( is there any fix for this ?

hongsa commented 7 years ago

On temporary, I use ./gradlew assembleRelease, move to real device to apk file.

PetersonLian commented 6 years ago

Any solutions?

mistypix commented 6 years ago

What i found was that you have to go to recent apps list in your android phone, and clear the Expo app from the list, and open the app again, then it will show the changes made in app.js file... i hope it helps

klaszlo8207 commented 6 years ago

When I am run the app in the emulator the images updating. But when I run my app on a real device I get the old images on that. I just changed an image logo in the assets folder. Wtf happening?

st0ffern commented 6 years ago

Are the images located inside the project folder? Try restarting the watchdog

raphcadiz commented 6 years ago

Hi guys, any fix for this? After we deployed our app for production we got this problem. The changes I made is not longer reflecting on the application. I run command react-native run-android to test the android version

debajyoti-thetaonelab commented 6 years ago

Hi! Reloading(shake/dev menu and reload option) from android device isn't loading my new changes! But If I restart RN packager with --reset-cache and reloads from android, it works. Turning on hotreload doesn't works either! After saving code in VSCode rn hotreloads but it doesn't changes. (the changes includes style changes etc, no local resource require) I have tried to clear watchman cache watchman watch-del-all ; watchman shutdown-server

Ilario17 commented 6 years ago

Any news? I also have this issue.

Dhrupal commented 6 years ago

Please help

DrWongKC commented 6 years ago

I have the same problem as well.

poepanda commented 6 years ago

I have sort of the same issue today, the app on android suddenly keep an old version of the code and doesn't reflect any changes in the current code. Maybe it's affected by a lot of cache clean kinds of stuff I did yesterday.

1.I was looking around and found this bundle issue, it works for me https://stackoverflow.com/questions/44446523/unable-to-load-script-from-assets-index-android-bundle-on-windows/44476757#44476757

  1. But after that, I got another issue with Development menu (Not able to open it) Here is the solution I found for that Open MainApplication.java in the android/app/src/main/java/{packagename} directory ,delete the following code if exist
import com.facebook.react.BuildConfig;

BuildConfig.DEBUG should be true in debug mode, while in com.facebook.react.BuildConfig it is always false.

Hope this is useful :)

zengkm commented 6 years ago

@poepanda It works for me .Thank you!

klaszlo8207 commented 6 years ago

I just restarted the pc and worked again like a charm. It is sometimes frustrating.

BipinAle commented 6 years ago

This worked for me. I had same issue but solved exporting path

  1. echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
  2. echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >>~/.bash_profile then
  3. source ~/.bash_profile
jasmineelamblakatt commented 6 years ago

Below code worked for me...

  1. Perform adb reverse..check below got to platform-tools in cmd C:\SetUps\AndroidSetUp\sdk\platform-tools> adb reverse tcp:8081 tcp:8081
  2. Then delete any bundle file if present in assets folder 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
  3. react-native run-android
Zedonboy commented 6 years ago

@jasmineelamblakatt it only works for the time being. If i change any code in App.js, you dont expect a developer to go through those steps, in other to update the index.android.bundle file.

i have same issue, but i want it to automatically update index.android.bundle file

fuyue111 commented 6 years ago

dev setting set the ip to 127.0.0.1:8081 worked for me.

luizguilhermefr commented 6 years ago

This bug is happening to me when using physical device on same wi-fi network.

This doesn't happen to me when using emulator on same host PC.

deva11 commented 6 years ago

Follow the procedure first time.

mkdir android/app/src/main/assets

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

react-native run-android

Execute the Following code every time when you run your code in physical device.

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

totoro0103 commented 6 years ago

Thank @deva11 . It's work for me

mistypix commented 6 years ago

Moving to flutter.

On Feb 26, 2018 8:33 AM, "hoangphan92" notifications@github.com wrote:

marry thank @deva11 https://github.com/deva11 . It's work for me

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/9977#issuecomment-368376884, or mute the thread https://github.com/notifications/unsubscribe-auth/ANq30KJ3ArKITIshElCsc5b3IC8_Yj1hks5tYh7jgaJpZM4KAJV8 .

hongtou820 commented 6 years ago

hi ~ when i edit the "App.js" how i refresh the page on my device

arakkanjibin commented 6 years ago

@poepanda Thanks, issue got resolved.

RobertTadevosyan commented 6 years ago

_# ###SOLUTION

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

OUTPUT will be : c:\Users\lenger\Desktop\webrowser>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 Scanning folders for symlinks in c:\Users\lenger\Desktop\webrowser\node_modules (43ms) Scanning folders for symlinks in c:\Users\lenger\Desktop\webrowser\node_modules (38ms) Loading dependency graph, done. bundle: start bundle: finish bundle: Writing bundle output to: android/app/src/main/assets/index.android.bundle bundle: Done writing bundle output

and after

Run react-native run-android again, you will find your modification work.

from https://lengerrong.blogspot.am/2018/01/react-native-run-android-do-not.html

mjmasn commented 6 years ago

I'm seeing this issue when running two physical Android devices via USB, 90% of the time if I switch branch in git, then run react-native run-android both devices will install the new apk successfully but only 1 device will have the updated js bundle :expressionless: Even uninstalling the APK from both devices and running watchman watch-del-all immediately after changing branch has no effect. Usually running react-native run-android once or twice more works. As you might imagine this is making code review painful because I have to guess if I'm actually running the latest changes or not...

Etregoning commented 6 years ago

I'm having this same issue. None of the solutions mentioned here or anywhere else have worked for me.