简体   繁体   English

Android 错误:AAPT:错误:找不到资源 drawable/ic_bot(又名 com.example.chatbot:drawable/ic_bot)

[英]Android error: AAPT: error: resource drawable/ic_bot (aka com.example.chatbot:drawable/ic_bot) not found

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.当我尝试运行应用程序时在 Build Output 中出现错误:ERROR:C:\Users\xxxxxxxx\AndroidStudioProjects\Chatbot\app\src\main\res\layout\bot_msg.xml:18: AAPT: error: resource未找到 drawable/ic_bot(又名 com.example.chatbot:drawable/ic_bot)。

Here's the code in bot_msg.xml:这是 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.我是初学者。

Make sure you have an image named ic_bot in your project directory C:\.....\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\确保在项目目录C:\.....\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\中有一个名为ic_bot的图像

Android creates a Drawable resource for any of .png, .jpg, or.gif files when you save them in the res/drawable/ directory. Android 为任何.png, .jpg, or.gif文件创建一个 Drawable 资源,当您将它们保存在 res/drawable/ 目录中时。

In your case:在你的情况下:

 ..\AndroidStudioProjects\Chatbot\app\src\main\res\drawable\

The filename is used as the resource ID.文件名用作资源 ID。 compiled resource datatype will be Resource pointer to a BitmapDrawable.编译后的资源数据类型将是指向 BitmapDrawable 的资源指针。 and resource reference will be:资源参考将是:

In Java: R.drawable.filename在 Java: R.drawable.filename

In XML: @[package:]drawable/filename在 XML 中: @[package:]drawable/filename

The following application code retrieves the image as a Drawable:以下应用程序代码将图像检索为 Drawable:

Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);

暂无
暂无

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

相关问题 Android Studio - 错误:找不到资源可绘制/abc_ic_ab_back_mtrl_am_alpha(又名 com.instacoin:drawable/abc_ic_ab_back_mtrl_am_alpha) - Android Studio - Error:resource drawable/abc_ic_ab_back_mtrl_am_alpha (aka com.instacoin:drawable/abc_ic_ab_back_mtrl_am_alpha) not found 如何修复 AAPT:错误:找不到资源 drawable/tt(又名 com.example.polyresults:drawable/tt) - How to fix AAPT: error: resource drawable/tt (aka com.example.polyresults:drawable/tt) not found 我无法解决错误:找不到资源可绘制/ abc(又名com.example.myapplication:drawable / abc) - I cant solve error:resource drawable/abc (aka com.example.myapplication:drawable/abc) not found Android 包括布局:使用数据绑定传递可绘制参数给出错误:AAPT:错误:找不到属性 mysrc(又名 com.example.APPNAME:mysrc) - Android include layout: pass Drawable parameter using data binding gives error: AAPT: error: attribute mysrc (aka com.example.APPNAME:mysrc) not found Unity项目中的错误:找不到与给定名称匹配的资源(在“ icon”处,值为“ @ drawable / ic_launcher”) - Error in Unity project : No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher') 错误:在eclispe中找不到与给定名称(在&#39;srcCompat&#39;,值为&#39;@ drawable-hdpi / ic_launcher&#39;)匹配的资源 - Error: No resource found that matches the given name (at 'srcCompat' with value '@drawable-hdpi/ic_launcher') in eclispe 每当在 android 工作室中打开新项目时,可绘制文件中的 ic_launcher_background.xml 文件中的错误 - Error in ic_launcher_background.xml file in drawable, whenever new project is opened in android studio ic_launcher.png AAPT:错误:在 Android Studio v4.1.1 中找不到文件 - ic_launcher.png AAPT: error: file not found in Android Studio v4.1.1 Android drawable ic_menu_star 不工作? - Android drawable ic_menu_star not working? AAPT:错误:找不到属性 buttonColor(又名 com.example.*appName*) - AAPT: error: attribute buttonColor (aka com.example.*appName*) not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM