简体   繁体   English

错误:文件名必须以 .xml 或 .png 结尾

[英]Error: The file name must end with .xml or .png

Even though I didn't choose photothumb.db as a drawable, I get an error saying photothumb.db should end with .xml or .png尽管我没有选择 photothumb.db 作为可绘制对象,但我收到一个错误,提示 photothumb.db 应该以 .xml 或 .png 结尾

my profilesmaller image is of type png我的profilesmaller的图像是png类型

Below are my codes以下是我的代码

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/profilesmaller"
    tools:context="charlenebuena.guest.HomeFragment">
</FrameLayout>

Below is my Gradle Console Message以下是我的 Gradle 控制台消息

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> C:\Users\Charlene Marie\AndroidStudioProjects\Guest\app\src\main\res\drawable\photothumb.db: Error: The file name must end with .xml or .png

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.72 secs

Android accepts only .png, .jpg, .gif and .xml files as drawable resources. Android 仅接受 .png、.jpg、.gif 和 .xml 文件作为可绘制资源。 If you have file .db file then put that file in assets folder.如果您有文件 .db 文件,则将该文件放在 assets 文件夹中。

I had a similar problem after I converted .png icons to .webp format.将 .png 图标转换为 .webp 格式后,我遇到了类似的问题。 The file was created in the xxhdpi folder and not used.该文件是在 xxhdpi 文件夹中创建的,但未使用。 I didn't remember creating or using photothumbs.db in any of my app's xml and java files.我不记得在我的任何应用程序的 xml 和 java 文件中创建或使用 photothumbs.db。 The error was cleared after simply deleting the photothumbs.db file.只需删除 photothumbs.db 文件即可清除错误。 Create a backup copy of the file anyway for safety before deleting it.为了安全起见,请在删除文件之前创建文件的备份副本。

Remove photothumb.db file from drawable to asset directory.将 photothumb.db 文件从 drawable 删除到资产目录。 If asset directory is not there then right click on main > New > directory > assets and then create.Place your db file there and you are good to go.如果资产目录不存在,则右键单击 main > New > directory > assets 然后创建。将您的 db 文件放在那里,您就可以开始了。

This happened to me when somehow (I have no idea how) one of my asset files got ended up in当我的一个资产文件以某种方式(我不知道如何)结束时,这发生在我身上

.../app/src/main/res/assets/model.tflite 

When it should have been at它应该在什么时候

.../app/src/main/assets/model.tflite

Moving it back fixed the problem.将其移回解决了问题。

Just change your image file extension from something(like ico etc) to png.只需将您的图像文件扩展名(如 ico 等)更改为 png。 It will work.它会起作用的。

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

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