How to add icons to React Native app

IconsReact Native

Icons Problem Overview


I am making a React Native app. I would like to customize the app icon (meaning the icon that you click on to start the app). I have Googled this, but I keep finding different types of icons that refer to different things. How do I add these types of icons to the app?

Icons Solutions


Solution 1 - Icons

iOS Icons

  • Set AppIcon in Images.xcassets.
  • Add 9 different size icons:
    • 29pt
    • 29pt*2
    • 29pt*3
    • 40pt*2
    • 40pt*3
    • 57pt
    • 57pt*2
    • 60pt*2
    • 60pt*3.

Images.xcassets will look like this:

Android Icons

  • Put ic_launcher.png in folders [ProjectDirectory]/android/app/src/main/res/mipmap-*/.
    • 72*72 ic_launcher.png in mipmap-hdpi.
    • 48*48 ic_launcher.png in mipmap-mdpi.
    • 96*96 ic_launcher.png in mipmap-xhdpi.
    • 144*144 ic_launcher.png in mipmap-xxhdpi.
    • 192*192 ic_launcher.png in mipmap-xxxhdpi.

Update 2019 Android

The latest versions of react native also supports round icon. For this particular case, you have two choices:

A. Add round icons: In each mipmap folder, add additionally to the ic_launcher.png file also a round version called ic_launcher_round.png with the same size.

B. Remove round icons: Inside yourProjectFolder/android/app/src/main/AndroidManifest.xml remove the line android:roundIcon="@mipmap/ic_launcher_round"and save it.

Otherwhise the build throws an error.

Solution 2 - Icons

I wrote a generator to automatically generate icons for your react native app from a single icon file. It generates your assets and it also adds them correctly to your ios and android project:

Update (04/09/2019)

We revamped our generator to be up to date with the ecosystem standards. You can now use @bam.tech/react-native-make.

You can install it using: yarn add @bam.tech/react-native-make in the react-native project

To use it react-native set-icon --path <path_to_png> --background <icon_background_color> --platform <android|ios>

And... that's it! Hope it can be useful for others :)

Recommendations:

Here are some improvements over the previous tool: 拾

  • No Yeoman dependency, it is now a react-native-cli plugin
  • No Image Magick dependency
  • Creates Adaptive icons for Android
  • Adds missing icons sizes for iOS

Solution 3 - Icons

I would use a service to scale the icon correctly. http://makeappicon.com/ seems good. Use a image on the larger size as scaling up a smaller image can lead to the larger icons being pixelated. That site will give you sizes for both iOS and Android.

From there its just a matter of setting the icon like you would a regular native app.

https://help.apple.com/xcode/mac/8.0/#/dev10510b1f7

https://stackoverflow.com/questions/5350624/set-icon-for-android-application

Solution 4 - Icons

I was able to add an app icon to my react-native android project by following this guy's advice and using Android Asset Studio

Here it is, transcribed in case the link goes dead:

How to upload an Application Icon in React-Native Android

  1. Upload your image to Android Asset Studio. Pick whatever effects you’d like to apply. The tool generates a zip file for you. Click Download .Zip.

  2. Unzip the file on your machine. Then drag over the images you want to your /android/app/src/main/res/ folder. Make sure to put each image in the right subfolder mipmap-{hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi}.

android/app/src/main/res

  1. Do not (as I originally did) naively drag and drop the whole folder over your res folder. As you may be removing your /res/values/{strings,styles}.xml files altogether.

Solution 5 - Icons

Android Studio has a very handy icon asset wizard called Image Asset Studio (user guide here). It's quite self explainatory, and has a few handy effects and it's built right in:

enter image description here

Screenshot from Android Studio 4.1.3 on Windows 10 enter image description here

Solution 6 - Icons

Someone made a very easy to use tool just for this task: https://www.npmjs.com/package/app-icon

>This simple tool allows you to create a single icon in your react-native project, then create icons of all required sizes from it. It currently works for iOS and Android.

I've used it. Made a 512x512 png and then ran that tool and boom, done. Super easy.

Solution 7 - Icons

You'll need different sized icons for iOS and Android, like Rockvic said. In addition, I recommend this site for generating different sized icons if anybody is interested. You don't need to download anything and it works perfectly.

https://resizeappicon.com/

Hope it helps.

Solution 8 - Icons

This is helpful for people struggling to find better site to generate icons and splashscreen

Solution 9 - Icons

If you're using expo just place an 1024 x 1024 png file in your project and add an icon property to your app.json i.e. "icon": "./src/assets/icon.png"

https://docs.expo.io/versions/latest/guides/app-icons

Solution 10 - Icons

For setting the App launch icon for Android Devices in a React-Native project:

  • Take a high resolution image of your logo and place it inside your project directory. Preferably in [Project-DIR]/android/app/src/main/res/
  • Open Android Studio and run your React-native project.
  • In Android Studio's Project window, select the Android view
  • Right-click the res folder and select New > Image Asset
  • A "Configure Image Asset" window will open; Locate your high resolution image and place set it as your "Foreground layer".
  • Set your "Background Layer" if applicable
  • Click "Next" and continue to finish.
  • Run your application again to see the new app launch icon.

Official documentation can be found here: https://developer.android.com/studio/write/image-asset-studio

Solution 11 - Icons

I personally use this link to generate my desired icons https://appicon.co/

And for importing inside the application.

> For IOS Setup

Click on your project from Xcode ==>

then on the left side you will see your click on that ==>

Now you will see subfile name Images.xcassets click on that ==>

you icons size will be displayed on the right hand window ==>

simply drag and drop the icons which we have generated from https://appicon.co/ ==>

and your IOS ICON SETUP IS DONE.

> Moving to Android

We will go to Android ==> app ==> src ==> main ==> res

Here you will various folders named mipmap-hdpi till xxxhdpi ==>

Drag the icons from the specific folder to your project specific folder. Happy coding!

Solution 12 - Icons

Use this library to make your work easier. It will automate your Icon generation process

https://www.npmjs.com/package/@bam.tech/react-native-make

Solution 13 - Icons

To import icons on React Native if you want the icons without having the pictures, then react-native-vector-icons would be the best one. You can use it if you don't want to download the icons and use it in your project.

Solution 14 - Icons

I would like to suggest to use react-native-vector-icons to import icons to your project. As you use vector icons, you don't need to worry much on icon scaling side. While using the package you are able to use all popular icon set such as fontawesome, ionicons etc..

Besides these iconsets you can also bring your own icons too to your react-native project by packing your icons as a ttf file and you can import that ttf directly to both android and ios project. You can utilise the same react-native-vector-icons library to manage those icons

Here is a detailed procedure to setup custom icons

https://medium.com/bam-tech/add-custom-icons-to-your-react-native-application-f039c244386c

Solution 15 - Icons

You can import react-native-elements and use the font-awesome icons to your react native app

Install

npm install --save react-native-elements

then import that where you want to use icons

import { Icon } from 'react-native-elements'

Use it like

render() {
   return(
    <Icon
      reverse
      name='ios-american-football'
      type='ionicon'
      color='#517fa4'
    />
 );
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdam KatzView Question on Stackoverflow
Solution 1 - IconsRockvicView Answer on Stackoverflow
Solution 2 - IconsAlmouroView Answer on Stackoverflow
Solution 3 - Iconsrmevans9View Answer on Stackoverflow
Solution 4 - IconsmixophrygianView Answer on Stackoverflow
Solution 5 - IconsRyan KnellView Answer on Stackoverflow
Solution 6 - IconsjcollumView Answer on Stackoverflow
Solution 7 - IconsjakobinnView Answer on Stackoverflow
Solution 8 - Iconsishab acharyaView Answer on Stackoverflow
Solution 9 - IconsRamon SchmittView Answer on Stackoverflow
Solution 10 - IconsAwshaf IshtiaqueView Answer on Stackoverflow
Solution 11 - Icons17bcs4133 Vishesh GuptaView Answer on Stackoverflow
Solution 12 - IconscetricView Answer on Stackoverflow
Solution 13 - IconsSnehendu RoyView Answer on Stackoverflow
Solution 14 - IconsManzoor SamadView Answer on Stackoverflow
Solution 15 - IconsudayView Answer on Stackoverflow