React-Native: Application has not been registered error

后端 未结 23 1944
無奈伤痛
無奈伤痛 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:08

    you need to register it in index.android.js / index.ios.js

    like this:

    'use strict';
    
    import {
        AppRegistry
    } from 'react-native';
    
    import app from "./app";
    
    AppRegistry.registerComponent('test', () => app);
    
    0 讨论(0)
  • 2020-12-22 19:11

    This can also be due to Root component name starts with lowercase.

    Recorrect it or rather create the project once again with a PascalCase name.

    e.g. ignite new HelloWord

    0 讨论(0)
  • 2020-12-22 19:12

    First of all you must start your application:

    react-native start
    

    Then, you must set your application name as the first argument of registerComponent.

    It works fine.

    AppRegistry.registerComponent('YourProjectName', () => YourComponentName);
    
    0 讨论(0)
  • 2020-12-22 19:13

    Rather than changing the name in AppRegistry ,

    Run react-native init Bananas , this will create react boilerplate code for Bananas project and AppRegistry.registerComponent will automatically point to bananas

    AppRegistry.registerComponent('Bananas', () => Bananas);
    
    0 讨论(0)
  • 2020-12-22 19:15

    I had the same problem. I was using Windows for creating a react native app for android and was having the same error. Here's what worked.

    • Navigate to the folder ANDROID in your root.
    • Create a file with name : local.properties
    • Open it in editor and write :

    sdk.dir = C:\Users\ USERNAME \AppData\Local\Android\sdk

    • Replace USERNAME with the name of your machine.

    Save and run the app normally. That worked for me.

    0 讨论(0)
  • 2020-12-22 19:16

    The issue will also appear when, in index.js, you have named the app differently from the name you gave it for the android/ios package; probably this happened when you've ejected the app. So be sure that when calling AppRegistry.registerComponent('someappname', () => App), someappname is also used for the native packages or viceversa.

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