Skip to content

How to change app name? #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MartinOrtiz opened this issue Jan 23, 2018 · 6 comments
Closed

How to change app name? #465

MartinOrtiz opened this issue Jan 23, 2018 · 6 comments

Comments

@MartinOrtiz
Copy link

MartinOrtiz commented Jan 23, 2018

Apparently all hell breaks loose when you try to change the name...
(this is for android build on Windows 10 pc)

The way you're supposed be able to do this is....

  1. delete android folder
  2. in package.json, provide new name for app
    ...
    "name": "rxp-jupiter",
    ...
  3. in root folder for app, do
    react-native upgrade.

This will re-creacte the android folder using the new name in the appropriate files
But it is incorrect, as it uses the "-", when it should drop the "-"
for example, in MainActivity.java and MainApplication.java, it has
package com.rxp-jupiter;
and the path to the files also uses the "-"
android\app\src\main\java\com\rxp-jupiter\MainActivity.java
It SHOULD BE.....
package com.rxpjupiter; (with the "-" dropped)
and the path to the files, should also drop the "-"
android\app\src\main\java\com\rxpjupiter\MainActivity.java

Now if I go back to package.json, and change the name, to not use any dashes
"name": "rxpjupiter",
and do "react-native upgrade"
I have no issues, and I have to go to Android studio, and import the Android app (by clicking on android folder), it will ask to upgrade to gradle 4.0, which I do, then I can build the project, then if I go to Run->debug 'app' in Android Studio, it will install the app on the emulator that I have running.

At this point, I get an error about bundler server...

I then open a node.js command prompt and CD to folder, and do an "npm start"
Then in emulator I reload the app, I can see in command prompt the bundle server is now working...but at the end I then get the red screen on the emulator with this error : "Application rxpjupiter has not been registered"

So there is some place where rxpjupiter is not used or updated to it, or what, I don't know....

How do I properly change/update app name for ReactXP project?
How do I fix the "not been registered" error

@MartinOrtiz
Copy link
Author

ps. The ReactXP project creator ...
create-xp-app MyProject

Will NOT use "MyProject" as the name in package.json.
It will always be...
"name": "rxp-hello-world",

So I need to be able to change the app name somehow.

@erictraut
Copy link
Contributor

The name in you app’s package.json is irrelevant. You can ignore it or change it to anything you like. This field is used only for packages that are published through npm and referenced by other packages.

@MartinOrtiz
Copy link
Author

if I change the value of name in package.json, and then if I delete the android folder, and then in main folder (from node.js command prompt), I do an "react-native upgrade", it will recreate android folder and it will use the name in package.json in both ios + android files (MainApplication.java in android subfolder is just one example).

So the value of name in package.json is relevant.

@MartinOrtiz
Copy link
Author

Even though the name seems to be changed in the relevant android files.....there still is something missing because I can't run it in emulator, because it doesn't get registered somewhere...

I suspect it has to do with AppRegistry.registerComponent, but I don't see that being done anywhere.
If it is, it's buried underneath the covers....

@Fitzpasd
Copy link
Contributor

I'm not very familiar with these tools, but here's my guess to what's happening.

The code that react-native upgrade has generated is using a module name of rxpjupiter as the root level view of your application. This is probably somewhere in your MainActivity.java, I think there's a String getMainModuleName() function or something similar. What this is doing is telling RN to load the rxpjupiter component on app startup. But RN doesn't know about this component, hence the error you're getting.

To fix this, and get all the benefits of RXP, you should:

  1. Change that function to return RXApp
  2. In your index file, do a RX.UserInterface.setMainView(<rxpjupiter />);. This assumes that's what your main component is btw, otherwise use whatever you are using as root.

Be careful using react-native tooling and expecting it to work with RXP. Some will work as expected, but others will not. To answer your original question, Android apps set their name in AndroidManifest.xml, typically with a value in strings.xml.

@MartinOrtiz
Copy link
Author

AndroidManifest.xml, typically with a value in strings.xml.

This gets changed to new name...the main issue is, I should be able to at least create a new project with the RXP create-xp-app tool. I don't seem to be able to do this (the default project always uses "rxp-hello-world")

I'll check on #2, and see what is done in app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants