在我的项目没有产生R.java文件 [英] No generated R.java file in my project

查看:210
本文介绍了在我的项目没有产生R.java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的记事本教程,练习2 。我开始通过创建一个新的Andr​​oid项目,并选择的从源代码创建的导入下载的源文件的锻炼; Tibial。

I am doing the Notepad tutorial, exercise 2. I started by creating a new Android project and chose Create from source to import the downloaded source files for the excercise.

但现在我在Eclipse中得到许多错误,问题是,有没有产生 R.java 类。我该如何解决这个问题?文件夹 GEN / 是空的。

But now I get many errors in Eclipse, and the problem is that there is no generated R.java class. How can I solve this? The folder gen/ is empty.

我在 Notepadv2.java 错误和 RES /布局/ note_edit.xml 两者似乎是有关所生成的事实 R.java 缺失。

I have errors on Notepadv2.java and in res/layout/note_edit.xml and both seems to be related to the fact that the generated R.java is missing.

下面是我的进口在报表 Notepadv2.java

import android.R;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter; 

它们是由Eclipse的命令创建按Ctrl + Shift + O

推荐答案

项目并创下清除。这应该,除其他外,重新生成R.java文件。

Go to Project and hit Clean. This should, among others, regenerate your R.java file.

也摆脱任何进口android.R的。* 语句,然后执行清理我提到的。

Also get rid of any import android.R.* statements and then do the clean up I mentioned.

显然,尤纳斯问题涉及到不正确的目标构建设置。他的目标版本设置为的Andr​​oid 2.1(SDK V7)的,他的布局XML中使用的的Andr​​oid 2.2(SDK V8)的元素(布局参数 match_parent ),因为这有没有​​办法让Eclipse来正确地产生由此引起的一切问题R.java文件。

Apparently Jonas problem was related to incorrect target build settings. His target build was set to Android 2.1 (SDK v7) where his layout XML used Android 2.2 (SDK v8) elements (layout parameter match_parent), due to this there was no way for Eclipse to correctly generate the R.java file which caused all the problems.

这篇关于在我的项目没有产生R.java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆