168

I'm trying to figure out how to change a ReactNative app name. The installed APK on my device is simply "App", with the Android icon. How can I change this?

I've tried changing package.json and re-running react-native upgrade but it didn't update AndroidManifest.xml

Overload119
  • 5,124
  • 5
  • 29
  • 34

22 Answers22

235

The generator does not override the strings.xml file located in android/app/src/main/res/values/, so you have to change the app_name variable manually

Mufaddal Hamid
  • 281
  • 3
  • 12
diedu
  • 19,277
  • 4
  • 32
  • 49
115

For Android

Modify displayName in app.json file

Modify app_name in android/app/src/main/res/values/strings.xml

then Run these commands one by one

cd android
./gradlew clean
cd ..
react-native run-android

For iOS

Modify Display Name in Project target (General Tab)

Select your application project as Host Application in Project target for testing (General Tab)enter image description here

Chhay Rith Hy
  • 1,359
  • 1
  • 7
  • 4
72

Try react-native-rename this npm package will ease the process

This package assumes that you created your react-native project 
using react-native init.

Note: This package does not attempt to properly rename build artifacts such as ios/build or Cocoa Pod installation targets. After renaming your project you should clean, build, and reinstall third party dependencies to get it running properly with the new name.

// in project directory

   npx react-native-rename <newName>
Paul Nyondo
  • 2,126
  • 2
  • 23
  • 30
  • 7
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/16498360) – m_callens Jun 22 '17 at 13:38
  • 2
    issue addressed – Paul Nyondo Jun 22 '17 at 15:30
  • The command should be `react-native-rename`. I couldn't edit because edits have to be > 6 characters :( – mchandleraz Sep 22 '17 at 20:09
  • Rename command says-"Directory should be created using react-native init"! – Rahul Rastogi Oct 24 '17 at 06:45
  • Adding anything globally with `yarn` is a poor practice. I would advise against it. As noted in their doc "For the vast majority of packages it is considered a bad practice to have global dependencies because they are implicit." – Mike S. Jun 13 '18 at 18:40
  • 2
    @MikeS. this is not a bad practice since it is NOT a project dependency but a tool, and having them as project dependencies is indeed a bad practice. Is like CRNA, you should have it as a global tool – Gustavo Topete Jul 24 '18 at 18:43
  • 1
    i have some issue with a package name ! i'm using firebase in my app and say > Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package name 'com.myapp' – DevAS Mar 23 '19 at 01:47
  • 36
    WARNING: Do not use this library. it will ruine your project. Never use this. – M.R.Safari Apr 17 '19 at 10:56
  • This package is DOPE. Saved my bacon – bobber205 Apr 29 '19 at 22:21
  • 42
    DO NOT USE. As of this writing, this package is deprecated / unmaintained and will make your project unusable. – SQueryL May 12 '19 at 13:16
  • It is not a project dependency and worked fine for me anyway. I will update my feedback in case it causes any issue – cherucole Jul 20 '20 at 12:17
  • @SQueryL did it caused any problem yet? It's working for me. – Zeeshan Ahmad Khalil Feb 09 '21 at 11:52
  • I'm not sure if it's an issue with Persian names or it ignores spaces in the name in general. Any way, it did not handle sth like "اسم اپ" very well. – Amin Dannak Feb 20 '21 at 06:29
  • This package works wonders. Note that if you have already manually renamed certain parts of your project before running the `react-native-rename` command, it will not work and you'll have to revert those changes – wisenickel Feb 24 '22 at 01:44
  • 1
    Gosh an npm package just to rename an app name? – user5305519 May 15 '22 at 08:57
58

First of all: Open app.json file in your react-native project directory. And, just replace displayName json property's value in this file. e.g.:

{
    "name": "SomethingSomething",
    "displayName": "My New App Name"
}

For Android app: Open strings.xml file, replace the <string name="app_name"> tag's value to your new app name. e.g.:

<string name="app_name">My New App Name</string>

For iOS: Open info.plist, replace the value after <key>CFBundleDisplayName</key> to your app name. e.g.:

<key>CFBundleDisplayName</key>
<string>My New App Name</string>

Uninstall your previous app installed on your device. Use npm install in project main directory, in ios folder directory run pod install commands. Now, simply install app in your device.

Rahul Rastogi
  • 4,486
  • 5
  • 32
  • 51
  • If i want to change the Bundle Identifier? – Oliver D Oct 12 '20 at 16:35
  • @OliverD For Android, change application ID in android/app/build.gradle file and for iOS, change the Bundle Identifier in iOS project. Don't forget to re-configure your third-party accounts in case of google sign in, facebook sign in etc. – Rahul Rastogi Oct 14 '20 at 08:54
  • 1
    If you want everything clean you need also to open xcode and rename your app from there. – Oussama Bouthouri Feb 24 '21 at 04:39
  • This fixes the app name for iOS, thanks! But the Splash Screen still has the old app name. How do I update the app name on the Splash Screen? – Green Jan 20 '23 at 00:36
40

UPDATE 2021

React native version: 0.64.0

Android

Find and open following files and change as required.
\android\app\src\main\res\values\strings.xml

<resources>
    <string name="app_name">My App</string>
</resources>

app.json

{
  "name": "MyApp",
  "displayName": "My App"
}

iOS

Find and open the \ios\YourAppName\Info.plist and change as required.
NOTE: if your name has spaces use &#x2007; instead of spaces.

<key>CFBundleDisplayName</key>
<string>My&#x2007;App</string>
Charitha Goonewardena
  • 4,418
  • 2
  • 36
  • 38
36

The way I did this for android (hacky, but it works) is just changed the string app_name field in

android/app/src/main/res/values/strings.xml

It will change the name of your installed android app to whatever you put as the value.

Eduardo Cuomo
  • 17,828
  • 6
  • 117
  • 94
Steve Phuc
  • 1,168
  • 2
  • 11
  • 12
17

I find that, if you want to change both the app name and the package name (i.e. rename the entire app), the following steps are necessary:

  • Make sure you don't have anything precious (non-generated, manually copied resources) in the android/ and ios/ subfolders.

  • Delete both the android/ and ios/ folder.

  • Change the "name" entry in your package.json to the new name.

  • Change the app name in both your index.android.js and index.ios.js: AppRegistry.registerComponent('NewAppName', () => App);

  • Run react-native upgrade to re-generate the platform subfolders.

  • If you have linked resources (like custom fonts etc.) run react-native link.

  • If you have other generated resources (like app icons) run the scripts to generate them (e.g. yo).

  • Finally, uninstall the old app on each device and run the new one.

KlaasNotFound
  • 1,035
  • 10
  • 15
  • 10
    Just a note: I think step #1 should be `create a repo test branch first`. – Mike S. Jun 13 '18 at 14:54
  • 1
    As of today, there's a new npm package that alleges to minimize these issues, `react-native-git-upgrade`. But I can't get it to run using `yarn`. My project doesn't use `npm`, nor do I want to install it globally. So, trying to figure out my options. So far, `react-native-git-upgrade` fails from CLI – Mike S. Jun 13 '18 at 17:12
  • 1
    thanks a lot for you steps I followed some and it worked – Greco Jonathan Mar 04 '19 at 16:35
  • 1
    Also have to do a debug keystore https://stackoverflow.com/a/57438549/5900793 – Steffo Dimfelt Oct 27 '19 at 07:00
  • 5
    `react-native upgrade` does not generate platform subfolders anymore. – Dogu Deniz Ugur Jun 16 '20 at 11:15
  • This answer should no longer be valid since `react-native upgrade` does not create the subfolders anymore. I just followed these steps and now I'm left without these folders. – mikasa Apr 11 '22 at 03:44
13

If you are asking only for Android here is solution

Modify displayName in /app.json file

Modify app_name in android/app/src/main/res/values/strings.xml

then Run these commands one by one

cd android
gradlew clean
cd ..
react-native run-android
Mufaddal Hamid
  • 281
  • 3
  • 12
Salman Saleem
  • 223
  • 2
  • 9
11

If you don't have any thing precious in your android folder, you can delete the folder then run react-native upgrade then react-native android. These will recreate AndroidManifest.xml along with necessary files and folders. (Tried on 0.18 in Windows 10)

Green
  • 4,950
  • 3
  • 27
  • 34
8

for android android/app/src/main/res/values/strings.xml My Android App

for ios Just open it in xCode select project tab general just rename it.

Biswajit
  • 85
  • 2
  • 7
6

simply change <string name="app_name"> 'NEW_APP_NAME' </string> located in

[project_dir]/android/app/src/main/res/values/strings.xml

NOTE: recommended

react-native-rename

by Paul Nyondo maybe affect MainApplication.java file, DON'T USE IT!

saeed eivazi
  • 818
  • 1
  • 7
  • 14
5
Change the name at \android\app\src\main\res\values\strings.xml,  
app.jon, and ./android/app/src/main/java/MainActivity.java

    **strings.xml**
    <resources>
        <string name="app_name">NewAppName</string>
    </resources>
    
    **app.json**
    {
      "name": "NewAppName",
      "displayName": "NewAppName"
    }
    
    **MainActivity.java**
      @Override
      protected String getMainComponentName() {
        return "NewAppName";
      }

Then run these commands on terminal


    cd android  
    ./gradlew clean   
    cd ..  
    npx react-native run-android

3

before changing the app name get your code's backup and then , Go to following path in and replace your app name with new app name and change i one more file app.json E:***\android\app\src\main\res\values\strings.xml

<resources>
    <string name="app_name">New Name</string>
</resources>

app.json

{
  "name": "oldName",
  "displayName": "New Name"
}
gauravsbagul
  • 79
  • 1
  • 2
  • 8
3

Change the app name in

  • \android\app\src\main\res\values\strings.xml
<resources>
    <string name="app_name">My App</string>
</resources>

-app.json

{
  "name": "MyApp",
  "displayName": "My App"
}

-package.json

 "name": "My App",

-also have to change return "appName" from android/app/src/main/java/com/companyName/appName/MainActivity.java

@Override
  protected String getMainComponentName() {
    return "My App"
  }
amboji alur
  • 175
  • 2
  • 7
2

You can try this

  1. Update displayName in app.json to the new name
  2. Delete ios/ and android/ directories
  3. Run react-native eject
  4. Run react-native link
Sarath Ak
  • 7,903
  • 2
  • 47
  • 48
  • 2
    eject seems not working if over React 0.6 upper, so the command show error: error Unrecognized command "eject". – tess hsu Dec 05 '19 at 10:31
2

Simply way

PROJECT >android > app > main > res > style

Then change the app name

Chaurasia
  • 494
  • 1
  • 6
  • 22
2

To change the name of the react-native Application

1 . Open ./android/app/src/main/java/[multiple folders]/MainActivity.java

 @Override
  protected String getMainComponentName() {
    return "NameOfTheApp";
  }
  1. Open android/app/src/main/res/values/strings.xml

    NEW APP NAME

  2. Change Name in App.json and package.json.

4.For clean android project run following command

cd android &&./gradlew clean

2

Update 2023 (React Native Version > 0.69)

The accepted answer works fine. However, there is a problem: all the built files are still based on the old name, which will cause unpredicted issues. So my suggestion is to delete ios and android folders and regenerate them. Here are the steps to do so:

  1. delete ios and android folders from the root directory

sudo rm -rf android/ ios/ (on Windows delete manually)

  1. add react native eject package

yarn add react-native-eject

  1. change the name of app in package.json and app.json to your desired new name

  2. regenrate ios and android folders

npx react-native eject

  1. link installed modules in ios

cd ios && pod install

  1. create a new android build (root directory)

react-native run-android

  1. create a new ios build (root directory)

react-native run-ios

NOTE: By following this approach you will lose icons and fonts that are already added to your project! However, in my opinion it totally worth it, because you solve this issue once and for all.

Amin Jafarlou
  • 336
  • 1
  • 10
  • Worked for me building for Android. In step 3 I also updated package-lock.json. I didn’t need step 5 but please could you clarify what this involves in case I need to build for iOS? – Will Jan 20 '23 at 07:38
  • Some libraries rely on native code, in that case you'll have to add these files to your app, otherwise the app will throw an error as soon as you try to use the library. "pod install" makes sure these native modules are linked to your react-native app. – Amin Jafarlou Jan 21 '23 at 09:53
  • Oh I see now what you meant. There needs to be a semi colon after cd ios; I thought you meant to cd into three directories and do something, but now I see that pod install is the second command. Would be better to have the two commands on two separate lines perhaps. – Will Jan 22 '23 at 17:38
  • Fixed, thanks for mentioning – Amin Jafarlou Jan 23 '23 at 11:13
  • It works perfectly. A very safe way to do it. – iarroyo Mar 02 '23 at 11:49
1

first of all create a whole backup of the project including node modules (in order to restore icons/phots ..etc in the future)

  1. Update name and displayName in app.json to the new name
  2. rename app folder the same as app name
  3. Delete ios/ and android/ directories
  4. delete ndoe modules
  5. update name in package.json (you must use new name for import & require() in your code. eg : import {x} from 'NewAppName/src/api')
  6. watchman watch-del-all
  7. rm -rf /tmp/haste-map-react-native-packager-*
  8. rm -rf /tmp/metro-bundler-cache-*
  9. restart pc
  10. sudo npm install
  11. react-native eject
  12. restore icons/images
  13. react-native link
  14. restart pc
  15. run app caution : you may have to setup things manually. in my case SplashScreen
1

Changed my app name in android/app/src/main/res/values/strings.xml as:

<resources>
    <string name="app_name">My App</string>
</resources>

and re-run using npx react-native run-android

kalyan
  • 135
  • 1
  • 4
1

The generator does not override the strings.xml file located in android/app/src/main/res/values/, so you have to change the app_name variable manually

And then run this command in android of root directory.

  • Mac

    .\gradlew clean

  • Window

    gradlew clean

and run in root direcoty > npm run android

HardCoding
  • 51
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – devpolo Mar 28 '23 at 16:52
0

Just adding to Chhay Rith Hy answer

If you are using Windows, you should use backslash or else you'll get an error "'.' is not recognized as internal or external command(...)"

So, instead of doing:

./gradlew clean

You should do:

.\gradlew clean

Lima
  • 3
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 28 '22 at 04:55