1

I'm trying to generate a release build of a react-native project, and am having issues with the ic_launcher_round.png not being included; it is simply showing the default android one.

I have the following icons:

android/app/src/main/res:

- mipmap-hdpi
  - ic_launcher.png
  - ic_launcher_round.png
- mipmap-mdpi
  - ic_launcher.png
  - ic_launcher_round.png
- mipmap-xhdpi
  - ic_launcher.png
  - ic_launcher_round.png
- mipmap-xxhdpi
  - ic_launcher.png
  - ic_launcher_round.png
- mipmap-xxxhdpi
  - ic_launcher.png
  - ic_launcher_round.png

Also, I have rounded icons specified in AndroidManifest.xml:

<application
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
>
  ...
</application>

When I run react-native run-android, the ic_launcher_round is included, and I can see my custom icon displayed on device. Following the steps from react-native for creating a release build:

cd android
./gradlew bundleRelease
cd .. && react-native run-android --variant=release

This successfully bundles, builds and installs the .apk file onto my phone, but without the correct icon; it displays the default android.

Has anyone seen this issue? I can't seem to google a solution that handles this new build process (for react-native 0.60, using ./gradlew bundleRelease instead of react-native bundle or ./gradlew assembleRelease)

Edit: Code and all plugins have been migrated from pervious version of react-native and function perfectly on debug and release builds; this question is specifically about lack of icon in release build with current settings. Please limit comments accordingly.

Vishal Dhanotiya
  • 2,512
  • 1
  • 13
  • 32
Tim Lewis
  • 27,813
  • 13
  • 73
  • 102
  • Have you cleaned android with gradlew clean? I also often found myself having to use ./gradlew assembleRelease instead of variant release because it didn't look like it was working as a release. – André Pinto Sep 03 '19 at 16:44
  • Yeah, I always run `./gradlew clean` before attempting to do other things. I'll try the `assembleRelease` thing too; maybe that'll work. – Tim Lewis Sep 03 '19 at 16:45
  • @AndréPinto, hmm, no, `assembleRelease` results in a build error `Could not find com.google.android.gms:play-services-vision-image-label:12.0.1`. Related issue to https://stackoverflow.com/questions/57733597/react-native-0-60-unable-to-run-app-with-react-native-run-android-java-lang-n (a different question I asked a few days ago that got no traction, but that I don't encounter when using `bundleRelease`) – Tim Lewis Sep 03 '19 at 18:31
  • Did you start this project with react-native 0.60 or you upgraded it from an older version? Also, I saw that the library `react-native-background-geolocation` has additional [configuration](https://github.com/transistorsoft/react-native-background-geolocation/blob/master/help/INSTALL-ANDROID-AUTO.md) for android when using it with react-native >= 0.60. I can say I use `react-native-camera` and `react-native-device-info` with no problems in the project I am working right now, but haven't used the `react-native-background-geolocation` yet. – André Pinto Sep 03 '19 at 19:16
  • As another option, you can upgrade if you have upgraded your project, you can try and rebuild your android folder with `react-native upgrade --legacy=true`, be aware that this proccess may delete your old files so you should do a backup first. – André Pinto Sep 03 '19 at 19:17
  • Yeah, brand new project with `react-native 0.60`, which I then ported all my files to and re-installed all plugins at their latest version. Was a week-long process to get to this point. And yes, that additional configuration has been included and verified to be working. I've got to the point that all builds are working and all components are functioning, it's literally just the icon missing on `release` build. – Tim Lewis Sep 03 '19 at 19:18
  • is Default android icon showing into all version or device of android or is any specific versionor device in which default icon showing? – Vishal Dhanotiya Sep 09 '19 at 15:38
  • @VishalDhanotiya All devices/versions. Showing in the play store as default icon as well. – Tim Lewis Sep 09 '19 at 15:40
  • @JonGoodwin Can you provide a little more detail? I'm not sure what that even means. Note I have deleted/recreated all `ic_launcher_round.png` files, not sure what you're saying by "make them point to your ic_launcher_round." Make what point? How? – Tim Lewis Sep 12 '19 at 20:05
  • delete all references to ic_launcher *OR* a least make them point to your *ic_launcher_round*. Try..test..despair...ask – Jon Goodwin Sep 12 '19 at 20:05
  • @JonGoodwin If I delete it, it uses the same icon (as that is the default Android one). I don't get any errors, the bundle is simply ignoring the icon. I've followed all the tutorials on adding and linking icons in Android, but it still uses the default one. I've tried to build this in Android Studio, but the build fails for a non-related issue. Trying to do the build process as detailed by `react-native`, the build is successful, but the icon is not linked. – Tim Lewis Sep 12 '19 at 20:15
  • As I say the icons do not **come from thin air** they are in your application resources. They are not placed there by magic. They are referenced. This is how the system works. – Jon Goodwin Sep 12 '19 at 20:18
  • @JonGoodwin Ok... Where are they referenced? Specifically with regards to the `react-native` build process. Can you provide me step-by-step details on how to confirm which icon is being used/how to override it? – Tim Lewis Sep 12 '19 at 20:21
  • It does matter where the are referenced if they don't exist. Then you will get an error **OR** it **will work**. Replace **all** icons you don't like with the one you do in **all** your resource folders. The system cannot display an icon that does not exist. – Jon Goodwin Sep 12 '19 at 20:25
  • @JonGoodwin Thanks for the help. I'll let you know if your solution works or not. – Tim Lewis Sep 12 '19 at 20:26
  • you can delete res folder. then build again. https://github.com/facebook/react-native/issues/21309 – Milon Sep 14 '19 at 15:38
  • @Milon I've done that plenty of times. This is not related to the duplicate resources issue, and the issue you linked uses RN 0.57, which does not use the same bundle command as 0.60. I'm looking for specific problems/solutions with that version. – Tim Lewis Sep 16 '19 at 14:12

2 Answers2

1

Rename both ic_launcher.png and ic_launcher_round.png to something else like my_ic_launcher.png

Make the change in manifest:

<application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/my_ic_launcher"
      android:roundIcon="@mipmap/my_ic_launcher_round"
>

Clean and build.

Ishita Singh
  • 297
  • 1
  • 6
0

The res folder in both src/main and src/release contained two files:

- ic_launcher_foreground.xml
- ic_launcher_background.xml

As well as a drawable folder with the same two files repeated. Simply removing these files (total of 8 files across 4 locations) and forcing the app to fallback to the .png files specified in the various mipmap folders allows the icon to display correctly in both debug and release builds.

Tim Lewis
  • 27,813
  • 13
  • 73
  • 102