【问题标题】:Render Android studio 2.3.3: File does not exist or is not a file渲染Android studio 2.3.3:文件不存在或不是文件
【发布时间】:2018-02-12 19:14:04
【问题描述】:

在 Android Studio 中渲染项目时遇到问题。它说文件不存在或不是文件,但它存在并且是文件。

我已经尝试了一切,将 SDK 级别降低到清单中所说的级别。我也换了主题,但是什么反应都没有,现在连模拟器都打不开了,说一直在尝试300秒才能打开。

请帮忙。我会附上图片。

This is the render problem

Here is the file that "doesn't exist" according to the problem

manifest 中的 SDK 版本是 22,这是我正在使用的版本:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />   

这是我调用这个文件的布局代码:

android:id="@+id/lyHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@xml/header_color"
android:paddingBottom="5dip"
android:paddingTop="5dip" >

这是文件的内容:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#71A2C7" />
</shape>

【问题讨论】:

  • 很可能,该文件不应该在res/xml/ 中。请编辑您的问题并发布该文件的内容以及您尝试使用它的布局资源。
  • 我添加了文件的内容和我尝试使用它的布局资源
  • res/xml/ 用于自定义 XML 或没有自己专用资源类型(例如,首选项、快捷方式、FileProvider 元数据)的框架 XML。在您的情况下,您正在定义一个可绘制对象。将该文件移至res/drawable-nodpi/,看看你是否有更好的运气。
  • 现在出现了这个问题: 标签需要一个 'drawable' 属性或定义可绘制对象的子标签
  • 您的问题中没有&lt;item&gt;。我的猜测是您项目中res/xml/ 中的button_* 文件都不属于那里。如果他们定义了可绘制对象,请将它们移至res/drawable-nodpi/

标签: android android-layout android-studio render


【解决方案1】:

您已将 Drawable 文件(文件包含 shape 标记)放入 xml 文件夹,因此 Android Studio 对其进行了错误解释。只需将其移至drawable 文件夹

【讨论】:

    猜你喜欢
    • 2017-12-01
    • 2020-05-29
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    • 1970-01-01
    • 2012-02-08
    • 1970-01-01
    相关资源
    最近更新 更多