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

时间:2016-12-07 07:33:53

标签: android android-drawable android-image android-background

即使我没有选择photothumb.db作为drawable,但我得到一个错误,说photothumb.db应以.xml或.png结尾

我的profilesmaller图片类型为png

以下是我的代码

<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>

以下是我的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

4 个答案:

答案 0 :(得分:3)

Android仅接受.png,.jpg,.gif和.xml文件作为可绘制资源。如果您有.db文件,则将该文件放在assets文件夹中。

答案 1 :(得分:0)

将photothumb.db文件从drawable删除到asset目录。如果没有资产目录,则右键单击 主要&gt;新&gt;目录&gt;资产,然后创建。在那里放置您的数据库文件,你很高兴。

答案 2 :(得分:0)

将.png图标转换为.webp格式后,我遇到了类似的问题。该文件是在xxhdpi文件夹中创建的,未使用。我不记得在我的应用程序的任何xml和java文件中创建或使用photothumbs.db。只需删除photothumbs.db文件,即可清除该错误。为了安全起见,无论如何都要创建该文件的备份副本。

答案 3 :(得分:-2)

只需将图像文件扩展名从某些内容(如ico等)更改为png即可。 它会起作用。