React native run-android do not updating modified code

后端 未结 21 3109
故里飘歌
故里飘歌 2020-12-13 06:02

I am using React native 0.52.0 and react-native-cli 2.0.1 on my Windows PC for android development. Despite all the changes i have made. When I run react-native run-an

相关标签:
21条回答
  • 2020-12-13 06:39

    After trying @SmoggeR_js answer and still if you have the same problem try following (Assuming that you have created keys and already signed the apk)

    1. Delete build inside android/app folder
    2. Delete build inside android folder
    3. run rm -rf $HOME/.gradle/caches/ to delete cache
    4. Open build.gradle --> android/app/build.gradle
    5. comment out this line apply from: "../../node_modules/react-native/react.gradle"
    6. Delete index.android.bundle file from assets folder ( android/app/src/main/assets/index.android.bundle)
    7. run following 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
    8. react-native run-android --variant=release (you have to generate signed keys and all the keys should updated in the gradle file ref (https://s-pace.github.io/react-native/docs/signed-apk-android.html)
    0 讨论(0)
  • 2020-12-13 06:40

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

    org.gradle.configureondemand = true

    0 讨论(0)
  • 2020-12-13 06:42

    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.

    0 讨论(0)
  • 2020-12-13 06:43

    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

    0 讨论(0)
  • 2020-12-13 06:46

    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.

    0 讨论(0)
  • 2020-12-13 06:49

    Silly mistake by me that not to save edits of App.js. After Saving data will reflect :)

    0 讨论(0)
提交回复
热议问题