react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
254 stars 2 forks source link

Invariant Violation: "AppName" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. #96

Open vikil143 opened 4 years ago

vikil143 commented 4 years ago

Environment

System: OS: Linux 5.4 Ubuntu 18.04.3 LTS (Bionic Beaver) CPU: (4) x64 Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz Memory: 1.96 GB / 15.47 GB Shell: 4.4.20 - /bin/bash Binaries: Node: 13.10.1 - ~/.nvm/versions/node/v13.10.1/bin/node Yarn: Not Found npm: 6.14.5 - ~/.nvm/versions/node/v13.10.1/bin/npm Watchman: Not Found SDKs: Android SDK: Not Found IDEs: Android Studio: Not Found Languages: Java: 1.8.0_265 - /usr/bin/javac Python: 2.7.17 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 npmGlobalPackages: react-native: Not Found

Upgrading version

Previous version "react": "16.9.0", "react-native": "0.61.5"

new version "react": "16.13.1", "react-native": "0.63.2"

Description

This error was getting when I upgrade my project from 61.5 to 63.2

super-potion commented 4 years ago

@vikil143 how did you fix this? stuck on the same issue

Mugambi-Ian commented 3 years ago

Change field name in ./app.json

{
  "name": "app-name",
  "displayName": "name"
}

to match ./android/app/src/main/java/com/{appName}/MainActivity.java

@Override
  protected String getMainComponentName() {
    return "app-name";
  }
MarufSharifi commented 3 years ago

Change field name in ./app.json

{
  "name": "app-name",
  "displayName": "name"
}

to match ./android/app/src/main/java/com/{appName}/MainActivity.java

@Override
  protected String getMainComponentName() {
    return "app-name";
  }

thank you so much! this changes solved my problem

theprantadutta commented 2 years ago

Change field name in ./app.json

{
  "name": "app-name",
  "displayName": "name"
}

to match ./android/app/src/main/java/com/{appName}/MainActivity.java

@Override
  protected String getMainComponentName() {
    return "app-name";
  }

Thanks a lot. I don't know how long I wasted on this.

Mugambi-Ian commented 2 years ago

@vikil143 I think this solves the issue

Gugan-raj commented 1 year ago

In App.json changed app name into original name

Aymanemadidi commented 3 months ago

Here is my app.json:

{
  "name": "app-name",
  "displayName": "MohamedNadi"
}

and here is my MainActivity.kt:

package com.MohamedNadi

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

class MainActivity : ReactActivity() {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  override fun getMainComponentName(): String = "app-name"

  /**
   * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
   * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
   */
  override fun createReactActivityDelegate(): ReactActivityDelegate =
      DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

but I still get

BUNDLE  ./index.js 

 ERROR  TypeError: Cannot read property 'NativeModule' of undefined, js engine: hermes
 LOG  Running "app-name" with {"rootTag":11}
 ERROR  Invariant Violation: "app-name" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
garryjstech commented 2 months ago

same issue.. anyone know how to solve this issue?

ZeeshiCh commented 3 weeks ago

Here is my app.json:

{
  "name": "app-name",
  "displayName": "MohamedNadi"
}

and here is my MainActivity.kt:

package com.MohamedNadi

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

class MainActivity : ReactActivity() {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  override fun getMainComponentName(): String = "app-name"

  /**
   * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
   * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
   */
  override fun createReactActivityDelegate(): ReactActivityDelegate =
      DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

but I still get

BUNDLE  ./index.js 

ERROR  TypeError: Cannot read property 'NativeModule' of undefined, js engine: hermes
LOG  Running "app-name" with {"rootTag":11}
ERROR  Invariant Violation: "app-name" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

i also got same issue did anyone fix

ganeshtak19 commented 1 day ago

+1 I am also facing this same issue. I checked all the solution mentioned here but still getting this issue. Did anyone FIND solution for this?