【发布时间】:2019-09-03 16:05:19
【问题描述】:
我正在尝试生成react-native 项目的release 构建,并且遇到了ic_launcher_round.png 不包括在内的问题;它只是显示默认的android 一个。
我有以下图标:
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
另外,我在AndroidManifest.xml 中指定了圆角图标:
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
>
...
</application>
当我运行react-native run-android 时,ic_launcher_round 包含在内,我可以看到我的自定义图标显示在设备上。按照react-native 的步骤创建release 构建:
cd android
./gradlew bundleRelease
cd .. && react-native run-android --variant=release
这成功地将.apk 文件捆绑、构建和安装到我的手机上,但没有正确的图标;它显示默认的android。
有人看过这个问题吗?我似乎无法通过谷歌搜索处理这个新构建过程的解决方案(对于react-native 0.60,使用./gradlew bundleRelease 而不是react-native bundle 或./gradlew assembleRelease)
编辑:代码和所有插件已从react-native 的先前版本迁移,并在debug 和release 构建上完美运行;这个问题特别是关于release 使用当前设置构建时缺少图标。请相应地限制 cmets。
【问题讨论】:
-
你用 gradlew clean 清理过 android 吗?我还经常发现自己不得不使用 ./gradlew assembleRelease 而不是变体版本,因为它看起来不像是一个版本。
-
是的,我总是在尝试做其他事情之前运行
./gradlew clean。我也会尝试assembleRelease的东西;也许这会奏效。 -
@AndréPinto,嗯,不,
assembleRelease导致构建错误Could not find com.google.android.gms:play-services-vision-image-label:12.0.1。与stackoverflow.com/questions/57733597/… 相关的问题(我几天前问的另一个问题没有引起注意,但我在使用bundleRelease时没有遇到) -
你是用 react-native 0.60 开始这个项目还是从旧版本升级它?另外,我看到库
react-native-background-geolocation在将它与 react-native >= 0.60 一起使用时有额外的configuration for android。我可以说我使用react-native-camera和react-native-device-info在我现在工作的项目中没有问题,但还没有使用react-native-background-geolocation。 -
作为另一种选择,如果你已经升级了你的项目,你可以升级,你可以尝试用
react-native upgrade --legacy=true重建你的android文件夹,注意这个过程可能会删除你的旧文件,所以你应该做一个先备份。
标签: android react-native release