React native run-android do not updating modified

2019-03-12 08:23发布

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-android, it builds successfully but when I run it, I get the default react native screen.

The result when I run react-native run-android- enter image description here

The app I get-

enter image description here

index.js

import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('albums', () => App);

app.js

import React from 'react'
import ReactNative, { Text } from 'react-native'

export default const App = () => {
  return (
    <Text>Hello World</Text>
  )
}

When i ran react-native init albums, it was just an index.js file that was created, there was no index.android.js or index.ios.js file What am I doing wrong?

11条回答
聊天终结者
2楼-- · 2019-03-12 08:38

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

查看更多
倾城 Initia
3楼-- · 2019-03-12 08:43

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
查看更多
在下西门庆
4楼-- · 2019-03-12 08:43

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

org.gradle.configureondemand = true

查看更多
成全新的幸福
5楼-- · 2019-03-12 08:45

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.

查看更多
啃猪蹄的小仙女
6楼-- · 2019-03-12 08:50

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.

查看更多
神经病院院长
7楼-- · 2019-03-12 08:51

This worked for me. Step 1)

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

Step2)

react-native start
查看更多
登录 后发表回答