Application is not Registered in react native

2020-04-17 07:11发布

问题:

I have a react native application and I changed the package name of the application using https://www.npmjs.com/package/react-native-rename. After that I tried to run the project but its saying that the application is not registered. I have tried the following steps also.

  1. Opened the project in android studio and make sure that the package name is changed and all the files are also in the same package name.

  2. Tried cleaning the old gradle files.

  3. Uninstalled the previously installed version of the app (The one which have the original package name.

Any help would be appreciated. Thanks in advance

回答1:

You need to check 2 files to make sure you have equal names there:

  1. index.js -> application name in the last line:

AppRegistry.registerComponent('YourAppName', () => App);

  1. app.json -> name property

In both places names should be equal (case sensitive).



回答2:

Have you changed the values ​​in the index.ios.js, index.android.js and app.json files?

There are some instructions here.



回答3:

android\app\src\main\java\com{someFolderName}\MainActivity.java

you landed up on this answer because still you are not able to solve the issue

open the file mentioned in above in title
this used for

  • Returns the name of the main component registered from JavaScript.
  • This is used to schedule rendering of the component.

look for method

    @Override
    protected String getMainComponentName() {
        return "AddYourNewNameHere";
    }

which might be returning a hard coded string replace it to desired name!!

EXTENDED TIP

ensure you clean your gradle demon as the project does not compile sometimes for that use following

  • cd android
  • gradlew clean