其他分享
首页 > 其他分享> > React native run-android不会更新修改后的代码

React native run-android不会更新修改后的代码

作者:互联网

我在我的Windows PC上使用React native 0.52.0和react-native-cli 2.0.1进行android开发.尽管我做了所有的改变.当我运行react-native run-android时,它会成功构建,但是当我运行它时,我会得到默认的反应原生屏幕.

当我运行react-native run-android-时的结果
enter image description here

我得到的应用程序 –

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>
  )
}

当我运行react-native init相册时,它只是一个创建的index.js文件,没有index.android.js或index.ios.js文件
我究竟做错了什么?

解决方法:

假设您位于正确的文件夹中,请尝试执行以下操作:

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/

如果您有index.android.js,请改为:

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/

然后只需执行react-native run-android.

标签:android,react-native,npm,react-native-android
来源: https://codeday.me/bug/20190930/1834936.html