Android 7.1.1中未显示应用程序图标启动器

8
我们正在实现一个圆形图标(具有前景和背景)和图标。
<application
    android:allowBackup="false"
    tools:replace="android:allowBackup"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:icon="@mipmap/logo" //normal logo
    android:roundIcon="@mipmap/logo_o" //Our logo with foreground and background
    android:name=".MyApplication"/>

适用于所有版本,但不适用于API 25。

在这里输入图片描述

我们的前台和后台代码如下:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/logo_background"/>
    <foreground android:drawable="@mipmap/logo_foreground"/>
</adaptive-icon>

你是通过将图像添加到mipmap资源文件中设置图标,还是使用了图像资产?你用的哪一个? - karthik
我有完全相同的问题,你解决了吗? - Olivier Mercier
@OlivierMercier 我也遇到了同样的问题,不过已经解决了 https://dev59.com/qq3la4cB1Zd3GeqPOYky#53199695 - petrsyn
7个回答

4

原因:

Android 8.0(API level 26)及以上版本支持自适应图标。更多信息请查看以下文档。看起来您没有为 API 级别在 25 及以下设备上提供后备图像。

如何解决:

仅在 API 26 及以上版本上使用自适应图标,并为旧设备提供您的应用程序图标的 png 图像。

您的文件夹结构应如下:

+-- _mipmap-anydpi-v26
|   +-- ic_launcher_round.xml
|   +-- ic_launcher.xml
+-- mipmap-mdpi
|   +-- ic_launcher_round.png
|   +-- ic_launcher.png
+-- mipmap-hdpi
|   +-- ic_launcher_round.png
|   +-- ic_launcher.png
+-- mipmap-xhdpi
|   +-- ic_launcher_round.png
|   +-- ic_launcher.png
+-- mipmap-xxhdpi
|   +-- ic_launcher_round.png
|   +-- ic_launcher.png
+-- mipmap-xxxhdpi
|   +-- ic_launcher_round.png
|   +-- ic_launcher.png

并将它们配置在您的清单文件中:

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

由于操作系统的形状决定了图标的外观,因此可以将相同的内容用于 ic_launcher_round.xmlic_launcher.xml。例如:

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

PNG图像ic_launcher_round.pngic_launcher.png应该包含前景层和背景层,形成一个单独的PNG文件,并且要分别适配您的应用程序图标的默认版本和圆形版本。


3

资源结构:

mipmap-anydpi-v25
   \  ic_launcher_round.xml
mipmap-anydpi-v26
   \  ic_launcher.xml
mipmap-*dpi
   \  ic_launcher.png

AndroidManifest.xml:

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

roundIcon资源添加资源重定向,以便在API 26及以上版本上保证有v26自适应图标。
values-anydpi-v26
   \  drawables.xml

drawables.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <mipmap name="ic_launcher_round">@mipmap/ic_launcher</mipmap>
</resources>

1
在我的情况下,这是由于删除了圆形图标的PNG /位图版本引起的。
我只保留了圆形图标的mipmap-anydpi-v26 XML版本,并删除了所有文件夹中的圆形图标,例如mipmap-hdpimipmap-mdpi等,认为它们是无用的。
当PNG位图的圆形版本被删除时,在所有Android版本(> 4.0)上都可以正常工作,但在Android 7.1 API级别25上除外。

0

我通过删除 mipmap-anydpi-v25 文件夹来解决了这个问题。

在最新版本的 Android Studio 上重新生成图标时,我注意到 Android Studio 不会生成 v25 文件夹,所以我将其删除了,然后问题得到了解决!:)


0

你应该在Android Studio中使用图像资源进行重新生成。 对于API 25,你应该生成圆形图标。


0

在Android Studio中,您可以使用图像资源生成带有圆角的图标,适用于任何API。例如,在您的情况下,您需要为API>=25生成它。


0

您可以添加其他图标:

enter image description here

在清单中:

<application
    android:name=".MiseApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"`

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