IT박스

반응 네이티브 : 응용 프로그램이 등록되지 않았습니다 오류

itboxs 2020. 6. 12. 21:50
반응형

반응 네이티브 : 응용 프로그램이 등록되지 않았습니다 오류


나는 현재 React-Native 튜토리얼을 진행하고 있습니다. 시작하기 자습서로 시작하여 새로운 반응 기본 프로젝트를 만들고 장치에서 프로젝트를 성공적으로 실행할 수있었습니다.

그런 다음 Props tutorial 을 시작하고 코드 스 니펫을 복사하고 프로젝트를 다시 실행하려고 시도했으며 화면에 다음 오류 메시지가 표시되었습니다.


프로젝트 이름과 등록 된 구성 요소가 일치하지 않아 오류가 발생한 것 같습니다.

하나의 이름으로 프로젝트를 시작했습니다. 즉

react-native init AwesomeApp

그러나 index.ios.js 파일에서 다른 구성 요소를 등록하십시오

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

이 때 해야

AppRegistry.registerComponent('AwesomeApp', () => Bananas);

고치십시오.


대부분의 경우 문제는 react-native start다른 터미널 또는 TMUX의 다른 탭 (TMUX를 사용하는 경우)에서 다른 (즉, React Native Packager) 서버가 실행되고 있다는 것입니다.

해당 프로세스를 찾아서 닫아야하므로 react-native run-ios예를 들어 실행 한 후에 는 해당 특정 응용 프로그램에 등록 된 새 패키저 서버가 설정됩니다.

다음을 사용하여 해당 프로세스를 찾으십시오.

ps aux | grep react-native

프로세스 ID (PID)를 찾고 kill명령 (예 :)을 사용하여 패키지 프로세스를 종료하십시오 kill -9 [PID]. launchPackager.command다른 운영 체제에 대해서는 잘 모르지만 macOS 에서 앱을 찾아야합니다 .

그런 다음 run-ios(또는 안드로이드)를 다시 실행 하십시오. 새 패키저 서버를 실행 한 후 새 경로를 볼 수 있어야합니다 (예 :

Looking for JS files in
   /Users/afshin/Desktop/awesome-app 

수정 MainActivity같이,

@Override
protected String getMainComponentName() {
    return "Bananas"; // here
}

내 솔루션은 "AppDelegate.m"의 모듈 이름을 변경하는 것입니다

...에서 moduleName:@"AwesomeProject"

moduleName:@"YourNewProjectName"


먼저 응용 프로그램을 시작해야합니다.

react-native start

그런 다음 애플리케이션 이름을 registerComponent의 첫 번째 인수로 설정해야합니다.

잘 작동합니다.

AppRegistry.registerComponent('YourProjectName', () => YourComponentName);

프로젝트에서 app.json 파일을 확인하십시오. appKey가없는 경우 추가해야합니다.

{
  "expo": {
    "sdkVersion": "27.0.0",
    "appKey": "mydojo"
  },
  "name": "mydojo",
  "displayName": "mydojo"
}

제 경우에는 MainActivity.java 에이 줄이 있습니다 .Ncli react-native-rename에서 cli를 사용할 때 누락되었습니다.

protected String getMainComponentName() {
    return "AwesomeApp";
}

분명히 이름을 앱 이름으로 바꿔야합니다.


나는 같은 문제가 있었고 근본 원인은 다른 반응 네이티브 폴더 (AwesomeApp)에서 패키지 프로그램을 실행 (반응 네이티브 시작)하고 다른 폴더에 다른 프로젝트를 생성했기 때문입니다.

새로운 앱의 디렉토리에서 패키저를 실행하면 해결되었습니다.


노드 서버가 다른 폴더에서 실행되고 있다고 생각합니다. 따라서 그것을 죽이고 현재 폴더에서 실행하십시오.

Find running node server:-

lsof -i :8081

Kill running node server :-

kill -9 <PID>

Eg:-

kill -9 1653

Start node server from current react native folder:-

react-native run-android


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


All the given answers did not work for me.

I had another node process running in another terminal, i closed that command terminal and everything worked as expected.


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

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.


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

Non of the solutions worked for me. I had to kill the following process and re ran react-native run-android and it worked.

node ./local-cli/cli.js start


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.


I figured out where the problem was in my case (Windows 10 OS), but It might also help in Linux as well( You might try).

In windows power shell, when you want to run an app(first time after pc boot) by executing the following command,

react-native run-android

It starts a node process/JS server in another console panel, and you don't encounter this error. But, when you want to run another app, you must need to close that already running JS server console panel. And then execute the same command for another app from the power shell, that command will automatically start another new JS server for this app, and you won't encounter this error.

You don't need to close and reopen power shell for running another app, you need to close node console to run another app.


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:

enter image description here

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

참고URL : https://stackoverflow.com/questions/38340360/react-native-application-has-not-been-registered-error

반응형