Getting the error in Build Output when I'm trying to run the app: ERROR:C:\Users\xxxxxxxx\AndroidStudioProjects\Chatbot\app\src\main\res\layout\bot_msg.xml:18: AAPT: error: resource drawable/ic_bot (aka com.example.chatbot:drawable/ic_bot) not found.
Here's the code in bot_msg.xml:
<!--below widget is for image of bot-->
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
android:src="@drawable/ic_bot" />
First time posting. Am a beginner.
CodePudding user response:
Make sure you have an image named ic_bot
in your project directory
C:\.....\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\
CodePudding user response:
Android creates a Drawable resource for any of .png, .jpg, or .gif
files when you save them in the res/drawable/ directory.
In your case:
..\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\
The filename is used as the resource ID. compiled resource datatype will be Resource pointer to a BitmapDrawable. and resource reference will be:
In Java: R.drawable.filename
In XML: @[package:]drawable/filename
The following application code retrieves the image as a Drawable:
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);