简体   繁体   English

Android启动器图标不起作用

[英]Android Launcher Icon not working

I have an Android app that I am currently developing. 我有一个我正在开发的Android应用程序。 I have created icons (.png) and placed them in the /res/drawable-hdpi (and ldpi & mdpi) folders. 我创建了图标(.png)并将它们放在/res/drawable-hdpi (和ldpi&mdpi)文件夹中。 In my manifest I have 在我的清单中,我有

<application android:icon="@+drawable/icon" android:label="@string/app_name">

my icons are all named icon.png. 我的图标都名为icon.png。

I have compiled the source and when I run it on the emulator, the icon shows up in the desktop launcher. 我编译了源代码,当我在模拟器上运行它时,图标显示在桌面启动器中。 But when I copy the apk to my actual phone, the desktop launcher shows the default package icon rather than my custom icon. 但是当我将apk复制到我的实际手机时,桌面启动器会显示默认包图标而不是我的自定义图标。 Although, funny enough when I am actually installing the app, the package manager does show the icon. 虽然,当我实际安装应用程序时,有趣的是,包管理器确实显示了图标。 But once it is installed, the icon does not show. 但是一旦安装,图标就不会显示。

How do I make my application icon show up as the launcher icon? 如何使我的应用程序图标显示为启动器图标?

Skip 跳跃

删除“@ + drawable / icon”中的“+”

I had the same problem, and I never used the "+" in the manifest. 我有同样的问题,我从未在清单中使用过“+”。 Rebooting&wiping emulator or restarting Eclipse did not work for me. 重新启动和擦除模拟器或重新启动Eclipse对我来说不起作用。

I simply solved renaming all the icon.png files to something different (eg iconq.png). 我只是解决了将所有icon.png文件重命名为不同的文件(例如iconq.png)。

I just had the same issue. 我刚才有同样的问题。 I renamed my icon to launch_icon and restarted Eclipse. 我将我的图标重命名为launch_icon并重新启动Eclipse。 Not sure which one did the trick but it worked after that 不确定是哪一个做了这个伎俩,但之后就可以了

Make sure that the Intent of your Launcher Activity is named MAIN ie, 确保Launcher活动的Intent名为MAIN,即

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Moreover, add the icon to your Drawable folders and then refer it in the application block of Manifest. 此外,将图标添加到Drawable文件夹,然后在Manifest的应用程序块中引用它。

<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

In my case, I was testing in a Nexus 5X device with the Android Nougat and the icon was correct, but in the emulator on the same android version but with the Pixel Launcher, the default icon were shown. 在我的情况下,我正在使用Android Nougat在Nexus 5X设备上进行测试并且图标是正确的,但是在相同Android版本的模拟器中但是使用了Pixel Launcher,显示了默认图标。 I saw that in my case I forgot to replace the android:roundIcon property in the manifest to use the new one. 我看到在我的情况下,我忘了替换清单中的android:roundIcon属性以使用新的属性。

Round Icon Resources 圆形图标资源

Apps can now define circular launcher icons, which are used on devices that support them. 应用程序现在可以定义圆形启动器图标,这些图标在支持它们的设备上使用。 When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration. 当启动器请求应用程序图标时,框架将返回android:icon或android:roundIcon,具体取决于设备构建配置。 Because of this, apps should make sure to define both android:icon and android:roundIcon resources when responding to launcher intents. 因此,应用程序应确保在响应启动程序意图时定义android:icon和android:roundIcon资源。 You can use Image Asset Studio to design round icons. 您可以使用Image Asset Studio设计圆形图标。

You should make sure to test your app on devices that support the new circular icons, to see how your circular app icons look and how they are displayed. 您应该确保在支持新圆形图标的设备上测试您的应用程序,以查看圆形应用程序图标的外观以及它们的显示方式。 One way to test your resources is to run the Android emulator and use a Google APIs Emulator System targeting API level 25. You can also test your icons by installing your app on a Google Pixel device. 测试资源的一种方法是运行Android模拟器并使用针对API级别25的Google API模拟器系统。您还可以通过在Google Pixel设备上安装应用来测试图标。

For more information about designing app launcher icons, see the Material Design guidelines. 有关设计应用程序启动器图标的详细信息,请参阅“材料设计”指南。

https://developer.android.com/about/versions/nougat/android-7.1.html#circular-icons https://developer.android.com/about/versions/nougat/android-7.1.html#circular-icons

It's possible to have different icons set for different components (ie Activity and Service). 可以为不同的组件(即活动和服务)设置不同的图标。 Make sure that you have the icon only defined for the application element, and nothing else. 确保您只为应用程序元素定义了图标,而没有其他内容。 This will guarantee that all components will have a the same icon, the one defined in the application. 这将保证所有组件都具有相同的图标,即应用程序中定义的图标。

For some reason it was the ROM I had on my phone (it was a gingerbread MIUI ROM). 出于某种原因,这是我手机上的ROM(它是姜饼MIUI ROM)。 I put a new ROM on my phone today and it works fine. 我今天在手机上放了一个新ROM,它工作正常。 Strange. 奇怪。

I had a similar problem. 我遇到了类似的问题。 I am running a custom rom (Cyanogen mod 7), and my solution was to simply reboot my device. 我正在运行一个自定义ROM(Cyanogen mod 7),我的解决方案是简单地重新启动我的设备。 After that, the icon appeared. 之后,出现了图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM