React native run-android do not updating modified code

只谈情不闲聊 提交于 2019-11-28 17:51:32

Assuming that you are in the right folder, try to do this:

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/

if you have index.android.js, do this instead:

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/

Then just execute react-native run-android.

Rob

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.

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

You are probably updating the wrong file and not calling it in the AppRegistry class.

Check (or post) your full index.android.js and make sure that the file that it is invoking and importing is the one you are actually modifying.

user2436649

This worked for me. Step 1)

rm -rf /usr/local/var/run/watchman && brew uninstall watchman && brew install watchman

Step2)

react-native start

in your terminal window go to your project folder and than try this command

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/

In my case, deleting below line in gradle.properties solved it.

org.gradle.configureondemand = true

lisandro

This worked for me:

In your project folder run this

c:\Users\lenger\Desktop\YourProjectFolder>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

Run react-native run-android again

I share the link where i found this solution: https://lengerrong.blogspot.com/2018/01/react-native-run-android-do-not.html

For me the problem was that I had removed internet permissions from my AndroidManifest.xml (since it technically wasn't needed). React Native uses that permission to connect your app to the development machine (and enable live-debugging).

<uses-permission android:name="android.permission.INTERNET" />

run the script below after that just do 1.gradlew clean 2.react-native link

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

If you are using index.android.js then follow the following steps:

Delete index.android.bundle within android/app/src/main/assets and then -

  1. 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/

  2. cd ./android

  3. ./gradlew assembleRelease -x bundleReleaseJsAndAssets

This comment on github fixed my problem.

@neonsec Cool, it do works !

and I find a reason why this happened

https://github.com/facebook/watchman/blob/4b98623e8fde17588f27494f3ae8f084b9b227d3/QueryableView.cpp#L48

it looks like when a .git/index.lock or a .hg/wlock file exist, watchman will do nothing

Solution: DELETE .git/index.lock file

## root app dir
rm -f .git/index.lock

otherlink: https://github.com/facebook/watchman/blob/4b98623e8fde17588f27494f3ae8f084b9b227d3/QueryableView.cpp#L48

Open package.json file and update this code.

"scripts": {
"android": "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",
"ios": "react-native run-ios"
},

Assuming that you are in the right folder, try to do this:

Run this command only it will automatically both commands.

npm run android

In your project directory, there is package.json file. You can add following code snippet in that json file under scripts:. After that you can run application using one command that is npm run android-windows. To work fine you should add below code script.

"android-windows": "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"

enter image description here

Open your Android Studio -> "Tools" menu -> "AVD manager" and right click the emulator you are using, choose "Wipe Data" then "Cold Boot Now" should solve the problem.

Fix it in 3 steps:

  1. Enable Live Reload
  2. Disable Hot Reloading
  3. In Dev Settings, uncheck JS Dev Mode

Now your app automatically updating everytime you made changes to your codes.

there was no index.android.js or index.ios.js file

In this case you have to follow the instructions on your mobile/emulator as below:

After saved your App.js, remember to type twice R in uppercase

For make it automatically changes, on Android emulator press CTRL + M (CMD + M on MacOS) or shake the Android device which has the running app and select Hot reloading (keep current state, change only the file you have changed) or Live reloading (reload the entire app).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!