【问题标题】:Cannot find my r.java file in android在 android 中找不到我的 r.java 文件
【发布时间】:2013-05-20 09:40:18
【问题描述】:

我是 android 的新手。我创建了一个项目来检查 android 中可用的文本字段。我在 string.xml 中添加了一些资源并构建了项目。我的 R.java 不是自动生成的。我从项目选项卡中只选择了“自动构建”。我已经多次清理我的项目并重新启动了 eclipse,但我的 r.java 没有生成。我的资源文件夹找不到任何错误。有人可以帮我解决这个问题吗?如果可能的话,还给我一些说明如何使用资源文件夹?请参考下面我的activity.xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Text_MainActivity"> 

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<EditText
    android:id="@+id/email_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="14dp"
    android:ems="10"
    android:hint="@string/email_hint"
    android:inputType="textEmailAddress"/>

<EditText
    android:id="@+id/launch_codes"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/email_address"
    android:layout_below="@+id/email_address"
    android:ems="10"
    android:hint="@string/enter_launch_codes"
    android:imeActionLabel="@string/launch"
    android:inputType="number"/>

<EditText
    android:id="@+id/postal_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/launch_codes"
    android:layout_below="@+id/launch_codes"
    android:ems="10"
    android:hint="@string/postal_address_hint"
    android:inputType="textPostalAddress"/>

<AutoCompleteTextView
    android:id="@+id/autocomplete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/postal_address"
    android:layout_below="@+id/postal_address"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="18dp"
    android:ems="10"
    android:hint="@string-array/countries_array">
</RelativeLayout>

提前致谢

【问题讨论】:

  • 从 Eclipse 中打开问题视图。它会给你关于这个问题的提示
  • @WinPhone7User 检查所有 xml 文件是否有错误。
  • 这是在 sdk 和 adt 插件更新后发生的吗?如果没有再次交叉检查您的资源文件
  • 'android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1"'....有没有可能把两者放在一起...??跨度>
  • 你用的是哪个版本的ADT,是22版吗?

标签: android android-resources r.java-file


【解决方案1】:

这已经被问过很多次了,可能是重复的问题。

但同样,您可以尝试清理并重建项目。如果问题仍然存在,请查看 res/ 文件夹,您可能会看到一个红色的 X 图标,显示其中一个 XML 文件已损坏。修复那个 XML,它可能会工作。

顺便说一句,您似乎没有关闭 xml 中的 AutoCompleteTextView 标记

【讨论】:

  • 同意,您的 xml 文件中一定有一些错误。仔细检查所有这些。
  • 我检查了我所有的 XML,没有错误。我什至没有看到任何红十字。我已经多次清理和重建我的项目。但我重复这个错误。
  • &lt;AutoCompleteTextView ... &gt;改为&lt;AutoCompleteTextView ... /&gt;
  • 我也添加了“/”并检查了。但没有用
  • @WinPhone7User 检查链接可能会对您有所帮助。 stackoverflow.com/questions/16636039/…
【解决方案2】:

在构建项目之前,右键单击 Android 项目,转到 --> Android 工具 ---> 修复项目属性。 完成后,然后右键单击项目并--->构建项目

它可能会解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    相关资源
    最近更新 更多