在PhoneGap/Cordova上,Android应用程序图标周围有白色圆圈的原因是什么?

7
我更新了PhoneGap,现在Android图标周围显示一个白色圆圈,就像我手机上一半的图标一样。我不想要这个白色圆圈。
附图显示了Arlo图标是正常的,然后是另外两个带有白色圆圈的图标。我的config.xml中列出的图标并不像这样。
我如何再次获得没有圆圈的图标,就像Arlo图标一样?
<platform name="android">
    <!--
        ldpi    : 36x36 px
        mdpi    : 48x48 px
        hdpi    : 72x72 px
        xhdpi   : 96x96 px
        xxhdpi  : 144x144 px
        xxxhdpi : 192x192 px
    -->
    <icon src="res/android/ldpi.png" density="ldpi" />
    <icon src="res/android/mdpi.png" density="mdpi" />
    <icon src="res/android/hdpi.png" density="hdpi" />
    <icon src="res/android/xhdpi.png" density="xhdpi" />
    <icon src="res/android/xxhdpi.png" density="xxhdpi" />
    <icon src="res/android/xxxhdpi.png" density="xxxhdpi" />
</platform>

enter image description here


请查看此示例:https://developer.android.com/studio/write/image-asset-studio.html - proofzy
如果您找到了解决方案,请更新。我遇到了同样的问题,只是在最近的构建中出现了。我猜测这可能与Android更新有关,因为我没有更改任何图标资源或重新生成(我正在使用ionic 3)。 - Andrew Barta
安德鲁,我现在发布了一个答案。希望它有所帮助。 - Caleb Pitman
4个回答

4

我确实修复了它,但我实在想不起来我具体做了什么。以下是我记得的一些事情。

1)我更新了cordova 8.0.0(不确定是否需要)

2)从config.xml中删除了所有android图标配置,除了我保留的:

<icon src="icon.png" />

3) 使用Android Studio生成自适应图标(非常简单):https://developer.android.com/studio/write/image-asset-studio#create-adaptive

每次使用phonegap prepare android(或cordova prepare android)时,都必须执行以下步骤,当然如果您删除/添加平台也需要执行。

4) 将从Android Studio生成的drawable/values文件夹/文件复制到approot/platforms/android/app/src/main/res中

5) 双重检查approot/platforms/android/app/src/AndroidManifest.xml是否具有此代码段:

<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">

可能有更好的方法,但我的应用程序正在使用自适应图标并且工作正常。希望这可以帮助您。很抱歉我不能记住所有细节!


这让我找到了正确的答案方向,谢谢!我在下面发布了我的解决方案,它不需要干扰平台目录。 - heykatieben

2

虽然有点晚,但我花了2个小时才解决了这个问题,并想分享一下!

我使用Android Studio创建图标,从一个新的空白项目开始。我通过这里的描述找到了图标生成器,尽管我觉得自己很幸运能够找到它,所以如果你需要它,你可以支付40美元查看视频,看看接口在哪里。然后,我将从该项目中/app/src/main/res文件夹生成的文件复制到我的/res/icons/android目录。

然后,我将以下内容添加到config.xml中(此块中还有其他内容,但这是相关的内容):

<platform name="android">
    <!-- Depend on v21 of appcompat-v7 support library -->
    <framework src="com.android.support:appcompat-v7:21+" />
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
    </edit-config>
    <resource-file src="res/icons/android/drawable/ic_launcher_background.xml" target="app/src/main/res/drawable/ic_launcher_background.xml" />
    <resource-file src="res/icons/android/drawable-v24/ic_launcher_foreground.xml" target="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" />
    <resource-file src="res/icons/android/mipmap-anydpi-v26/ic_launcher_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" />
    <resource-file src="res/icons/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher.png" target="app/src/main/res/mipmap-hdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher.png" target="app/src/main/res/mipmap-mdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" />
 </platform>

我不确定appcompat这行是否必要,如果你愿意,可以尝试不使用它。每次进行更改时,我还需要删除android平台并重新添加,以使其注意到更改。有一次,我还删除了.idea/caches文件夹以清除缓存。所有这些,现在它终于运行起来了!我认为这是比这里被接受的答案更好的解决方案,因为你没有与平台文件夹打交道,因此不需要每次手动复制,一劳永逸。希望这能为某人节省时间!


对于Ionic 4,请使用以下代码:<resource-file src="resources/android/d...在所有标签中使用此路径。 - Najam Us Saqib

0

我在Android 10上看到了这个白色边框,但在我的旧Android手机上,图标看起来完美无缺。

我猜这只是Android/Samsung更喜欢本地应用程序而不是Web-View的方式?


0

看起来应用程序从config.xml文件中获取了ldpi的第一个图标

尝试添加

<icon src="www/res/android/ldpi.png" /> 

在配置文件中,不包含密度参数、平台标签以外的代码,并且设置大小为1024x1024,以便于应用图标占满整个空间。


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