启动图标Xamarin Android没有找到

时间:2022-11-21 16:28:05

I'm doing a Hello World in Xamarin Android, but when I try to change the launcher icon, it throws the following error: "No resource found that matches the given name (at 'icon' with value '@drawable/icon')."

我正在Xamarin Android上做一个Hello World,但是当我尝试更改启动图标时,它会抛出以下错误:“没有找到匹配给定名称的资源(在'icon'和值'@drawable/icon')”。

Actually I don't have any "icon" in my resources, the icons' names are ic_launcher:

实际上,我的资源中没有任何“图标”,图标的名字是ic_launcher:

启动图标Xamarin Android没有找到

And my manifest looks like this:

我的清单是这样的

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="HelloWorldXamarinAndroid.HelloWorldXamarinAndroid" android:versionCode="1" android:versionName="1.0" android:installLocation="preferExternal">
    <uses-sdk android:minSdkVersion="16" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <application android:label="Hi android" android:icon="@drawable/ic_launcher"></application>
</manifest>

I've already cleaned the project and tried to rebuild it, can someone help me?

我已经清理了这个项目,并试图重建它,有人能帮我吗?

If I change all the images' names to "Icon.png" and the manifest with "@drawable/Icon", it works, my question is, why Xamarin doesn't work with other names

如果我把所有图片的名字都改成图标。“png”和“@drawable/Icon”的清单,我的问题是,为什么Xamarin不使用其他名称。

I found the problem, in Main Activity is set the icon too, so it's necessary to set the new name there too:

我发现这个问题,在主要活动中也设置了图标,所以也有必要设置新名称:

[Activity(Label = "HelloWorldXamarinAndroid", MainLauncher = true, Icon = "@drawable/ic_launcher")]
public class MainActivity : Activity
{
   ...
}

1 个解决方案

#1


1  

Right click the Droid project and select Android Manifest from the menu list. Under Application Icon you will see which icon the application is referencing.

右键单击Droid项目并从菜单列表中选择Android Manifest。在应用程序图标下,您将看到应用程序正在引用哪个图标。

Below is a picture of where the icon is being references.

下面是图标作为引用的图片。

启动图标Xamarin Android没有找到

#1


1  

Right click the Droid project and select Android Manifest from the menu list. Under Application Icon you will see which icon the application is referencing.

右键单击Droid项目并从菜单列表中选择Android Manifest。在应用程序图标下,您将看到应用程序正在引用哪个图标。

Below is a picture of where the icon is being references.

下面是图标作为引用的图片。

启动图标Xamarin Android没有找到