【问题标题】:Error: The file name must end with .xml or .png错误:文件名必须以 .xml 或 .png 结尾
【发布时间】:2016-12-07 07:33:53
【问题描述】:

尽管我没有选择 photothumb.db 作为可绘制对象,但我收到一条错误消息,提示 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

【问题讨论】:

  • 把photothumb.db的位置从drawable改成asset文件夹就可以解决问题了
  • @Char 可绘制的图像是否在文件名中具有 jpg 或 png 扩展名
  • photothumb 是图片还是数据库文件?
  • 您需要手动创建它检查我的答案,如果有帮助,请将其标记为正确,谢谢。

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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      将 photothumb.db 文件从 drawable 删除到资产目录。如果资产目录不存在,则右键单击 main > New > directory > assets 然后创建。将你的 db 文件放在那里,你就可以开始了。

      【讨论】:

        【解决方案4】:

        只需将您的图像文件扩展名从某些东西(如 ico 等)更改为 png。 它会起作用的。

        【讨论】:

        • 不推荐。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-10
        • 2015-08-12
        • 1970-01-01
        • 1970-01-01
        • 2018-08-04
        • 2018-01-19
        • 2021-09-08
        相关资源
        最近更新 更多