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:51

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

查看更多
ら.Afraid
3楼-- · 2019-03-12 08:55

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

查看更多
我命由我不由天
4楼-- · 2019-03-12 08:56

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/
查看更多
女痞
5楼-- · 2019-03-12 08:58

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

查看更多
Rolldiameter
6楼-- · 2019-03-12 08:58

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" />
查看更多
登录 后发表回答