问题
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.
回答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.
回答2:
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.
来源:https://stackoverflow.com/questions/57775250/react-native-0-60-ic-launcher-round-missing-for-release-bundle-build