“Invariant Violation: Application AwesomeProject has not been registered” When building for iOS device with static jsbundle

后端 未结 14 2305
刺人心
刺人心 2020-12-08 18:20

First off, I don\'t know react, but I figured deploying to an iOS device instead of the simulator wouldn\'t be too difficult to do with the docs. They were a bit sparse but

相关标签:
14条回答
  • 2020-12-08 18:47

    This is a lot later, but I was still experiencing this same issue. I tried to follow the restart everything path but it didn't fix it. What ended up fixing this for me was making sure my app.json 'name' field (used the same value in the 'displayName' field) matched the 'moduleName' field in my RCTRootView. matched those up and everything was groovy. Hope this helps someone out there.

    0 讨论(0)
  • 2020-12-08 18:47

    I am not fan of closing down everything so I dig this further.

    All I had to do is in my terminal window, I ran this command:

    ../lala/node_modules/react-native/packager/launchPackager.command ; exit; 
    

    My project name was "lala" , so find that there is node_modules in your project too.

    replace lala with your project name it should work.

    If there is an error says port is already in use:

     ERROR  Packager can't listen on port 8081
    

    Then you have two choices:

    • Kill already running program.
    • Or Change the port by going into : ../lala/node_modules/react-native/packager/packager.js then find your port number, example 8081, and replace with the port number that is not in use.
     var options = parseCommandLine([{
              command: 'port',
              default: 8082,
            }, {
    

    Save this file and then run the above command again.

    This way I can run multiple react(ors).

    0 讨论(0)
  • 2020-12-08 18:51

    I'm pretty sure @krazyeom's fix has nothing to do with this error. In my case, I fixed this by quitting the terminal that was running from a previous test app I had run. It seems the terminal was confused and was still hooked to a process whose project was no longer loaded in XCode. Try the following:

    1. Shut the Terminal spawned by React Native.
    2. Shut down XCode completely (may not be necessary).
    3. Re-open everything and re-run.
    0 讨论(0)
  • 2020-12-08 18:51

    Reference a nameless person.

    it works for me.


    I had almost the same problem you currently have a few days ago. For me it was a real device.

    From all my research, the solution that worked for me is the following:

    1. When you launch your app by typing react-native run-android, the error appears.
    2. So, reach your directory containing "adb.exe" ( for me it was
      C:\Users\username\AppData\Local\Android\Sdk\platform-tools\ )
    3. open a terminal from here. And type adb reverse tcp:8081 tcp:8081
    4. Then, by reloading the app on the phone, it should work.
    0 讨论(0)
  • 2020-12-08 18:54

    Did you change the name of the app that you're registering? I started the app with the name 'tricky', then later changed the name in this line:

    AppRegistry.registerComponent('MyNewApp', () => MyNewApp);
    

    and I started getting the invariant error.

    0 讨论(0)
  • 2020-12-08 18:55

    Usually, this Error nowadays has to do with the different versions of react-navigation being used.

    If you are using react-navigation 4.0

    "react-navigation": "^4.1.0",

    you have to make sure you are importing the right elements from the right places

    in your app.js

    import { createAppContainer, createSwitchNavigator } from 'react-navigation'
    import { createStackNavigator } from 'react-navigation-stack'
    import { createBottomTabNavigator } from 'react-navigation-tabs'
    

    This has helped me resolved the issue.

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