React-Native: Application has not been registered error

后端 未结 23 2164
無奈伤痛
無奈伤痛 2020-12-22 18:55

I am currently going through the React-Native tutorials. I began with the Getting Started tutorial, where I made a new react native project and successfully managed to run t

23条回答
  •  醉话见心
    2020-12-22 19:18

    After have read all the above, I have found that there could be another reason for this.

    In my case:

    react-native-cli: 2.0.1

    react-native: 0.60.4

    and following structure:

    First has to be noted that index.android is not been update in Android Studio when the build run by Metro builder( react-native run-android) so it has to be done manually. Also in Android studio does not "read" the

    app.json(created by default together with index.js, that renamed index.android.js):

     {
        "name": "authApp",
        "displayName": "authApp"
     }
    

    and so this like

    (in my case)

    import {authApp as appName} from './app.json';
    

    cause the fact that android studio does not know what authApp refer to. I fix for the moment referring to the app name with its string name and not using that import from app.json:

    AppRegistry.registerComponent('authApp', () => MyApp);
    

提交回复
热议问题