-7

I am developing an android app, I am trying to use the android image button. I have placed my image in the drawable folder and have this in my xml code:

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/PanicBtn"
    android:layout_marginTop="53dp"
    android:src="@drawable/panicbtn2"
    android:background="#ffffffff"
    android:contentDescription="" />

but each time I try to clean or debug the project, i keep getting this error: Error:(28, 22) No resource found that matches the given name (at 'src' with value '@drawable/panicbtn2'). Kindly help.

Benson Kiprono
  • 129
  • 1
  • 1
  • 12

2 Answers2

1

Sometimes, keeping the resource or image in your case in Drawable folder doesn't get added to ItemGroup/resource group.

You can simply open the .csproj file of your project and validate that if the image name is present in the < ItemGroup > section.. it must be like below if your image name and extension is panicbtn2.png:

<AndroidResource Include="Resources\drawable\panicbtn2.png" />

If it's not present there, then you can add the same there or you can right click the drawable folder and choose add files and simply add the file again through IDE/Visual Studio. That might help.

0

The error already states:

  • No resource found that matches the given name

Have you place a resource in drawable with that specific name "panicbtn2"?

Cheers.

alkathirikhalid
  • 887
  • 12
  • 18