React Native 应用图标问题。应用程序图标在应用程序菜单中未更改。

11

我正在使用 React Native 版本 0.58。

我已经在所有 mipmap 文件夹中用默认的 ic_launcher.png 替换了我的应用程序图标,但是应用程序图标仍然是默认的Android图标。我确定我的 PNG 尺寸与相应的 mipmap 文件夹是正确的。

谢谢。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
package="com.cekilissepeti">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>


2
请检查 'AndroidManifest.xml' 文件,在 'application' 标签下查看应用程序图标的地址。如果需要更多信息,请将您的清单代码添加到您的问题中。 - SamiAzar
你重新构建了你的应用程序而不是仅仅重新加载它吗? - Andrew
@Andrew 是的,我尝试了 react-native run-android 和 gradlew assembleRelease 两种方式。 - Ali Berat Çetin
2
你是否同时更改了 'ic_launcher.png' 和 'ic_launcher_rounded.png'?并且你是否尝试在设备上卸载并重新安装应用程序? - SamiAzar
1
@M.SamiAzar 是的,我两个都改了。它还是不行。 - Ali Berat Çetin
显示剩余4条评论
6个回答

11
我不得不从app/src/main/res文件夹中删除'mipmap-anydpi-v26'文件夹,其中包含两个xml文件,一个是普通图标的,另一个是圆形图标的。

6

我必须将文件重命名为与ic_launcher_roundic_launcher不同的名称,

然后我更新了AndroidMaifest.xml

<application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/launcher_new_name"
      android:roundIcon="@mipmap/launcher_new_name_round"


1

0

我遇到了同样的问题,使用类似于你的AndroidManifest.xml,使用yogenerator-rn-toolbox生成@mipmap/ic_launcher文件。

然而,由于Android使用圆形图标,而yo工具只生成ic_launcher而不是ic_launcher_round文件,因此我必须更新AndroidManifest.xml中的以下值并删除@mipmap/ic_launcher_round文件。

android:roundIcon=”@mipmap/ic_launcher”

希望这能有所帮助。
注意:最好不要使用方形图像作为圆形图标。在我的情况下,我正在等待this PR合并,这样generator-rn-toolbox就可以生成圆形图标和方形图标了。

0

检查 android/app/src/debug/res 中是否有图标。

一些自动图标生成工具会将图标放在所有 Android 版本中。

如果你在那里找到了图标,请删除它们。你应该只在 /main/res 文件夹下有一个图标位置。


0

我正在使用 react-native 版本为 0.68.2 ,我的应用程序图标显示异常

解决方案:

  1. 打开项目
  2. cd adroid->app->src->main->res
  3. 查看名为 'mipmap-anydpi-v26' 的文件夹
  4. 删除该文件夹
  5. 重新构建您的项目。

享受!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接