Eclipse提供错误,缺少R。java文件在最近更新后。

时间:2023-01-21 00:19:13

I have updated my SDK and ADT to the latest version, I have also update the Eclipse to Kepler the latest one after Juno.

我已经更新了我的SDK和ADT到最新版本,我也更新了Eclipse到开普勒最新的一个在Juno之后。

My ADT version is 22.0. After this update when I create a new project, I'm getting error, stating R cannot be resolved to a variable. I have imported import android.R;, but it is showing as unused import stating Don't include android.R here; use a fully qualified name for each usage instead.

我的ADT版本是22.0。当我创建一个新项目时,在此更新之后,我将得到错误,说明R不能被解析为一个变量。我已经导入了import android. r,但是它显示的是未使用的导入,说明不包括android。R;使用一个完全限定的名称来代替。

Same thing is happening with Mac OS also with the latest update. I have tried renaming activity_main.xml to other name, but still my R.java is not generated.

同样的事情也发生在Mac OS上,也有最新的更新。我试过重命名activity_main。xml到其他名称,但仍然是我的R。java没有生成。

Tried all the things which are possible. Cleaned the project, build the whole workspace. Nothing helping.

试过所有可能的事情。清理项目,构建整个工作区。没有什么帮助。

I think ADT or Eclipse compatibility is having problem after the update.

我认为ADT或Eclipse兼容性在更新后出现问题。

I have updated my whole SDK, here is the screenshot, but same problem is there.

我已经更新了我的整个SDK,这是截图,但是同样的问题在那里。

Eclipse提供错误,缺少R。java文件在最近更新后。

14 个解决方案

#1


172  

After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools. Eclipse提供错误,缺少R。java文件在最近更新后。

第一次更新到SDK工具后,您可能需要重新启动Android SDK管理器并安装一个新项目:Android SDK构建工具。

After installing this, clean your projects and rebuild.

安装完毕后,清理您的项目并进行重建。

#2


6  

Yesterday, I made an update with sdk manager, and I had the same problem as you. I fixed the issue: I have updated another time the android sdk (with the sdk manager tool), then I check update from eclipse for install the updated ADT plugin and I rebuid my project. "Android sdk Build-tools" from Android sdk manager is now rev 17 and now it is OK. I think the issue is from adt plugin from eclipse

昨天我和sdk经理做了一个更新,我遇到了和你一样的问题。我修正了这个问题:我已经更新了另一次android sdk(使用sdk管理器工具),然后我检查eclipse的更新,以便安装更新的ADT插件,并且我还拒绝了我的项目。Android sdk管理器的Android sdk构建工具现在是rev 17,现在可以了。我认为这个问题来自于eclipse的adt插件。

#3


2  

import android.R - remove this statement from all your classes and then do a clean your R file will be generated. if this did not work then check all your xml files for any errors and then do a clean. These 2 are the most common reasons for R file to go missing

导入安卓。从所有的类中删除该语句,然后生成一个干净的R文件。如果没有工作,那么检查所有的xml文件是否有错误,然后进行清理。这两个是R文件丢失的最常见原因。

#4


1  

Changes in your Build target also can effect R.java in Eclipse so

您的构建目标的更改也可以影响R。java在Eclipse中所以

Right Click Project >> Properties >> Android >> Select Latest(usually) Android API Platform >> Click OK

右键点击项目>>属性>> >> >选择最新(通常)Android API平台>>点击确定。

Hope this is helpful.

希望这是有帮助的。

#5


1  

Follow These steps...

遵循以下步骤……

  1. Right Click Your Project.
  2. 右键单击您的项目。
  3. Select Properties->Android Check Project Build Target and API Level.
  4. 选择属性->Android检查项目构建目标和API级别。
  5. Again come back and open Android Sdk Manager Chekc the Tools and make sure you are installed Curresponding Android SDK Build Tools.
  6. 再次回来,打开Android Sdk管理器Chekc工具,确保您已经安装了curresponse Android Sdk构建工具。

Eg : IF you selected api level 17 in properties you should install Android SDK Build Tools 17..

如果你选择了api级别17的属性,你应该安装Android SDK构建工具17..

#6


0  

Try this:

试试这个:

  1. make a backup of your projects on desktop

    在桌面上备份你的项目。

  2. close eclipse

    关闭eclipse

  3. delete your workspace

    删除您的工作区

  4. restart eclipse and import your projects again.

    重新启动eclipse并再次导入您的项目。

#7


0  

I had same problem.. I solved by doing the following:

我有同样的问题。我解决了以下问题:

  1. check all xml files and drawable files if there are any CAPITAL LETTERS in file name, if you have then change it to lower case, if you are using selector xml files then check the other files you are linking in those files..all should be lower case.

    如果文件名称中有大写字母,请检查所有的xml文件和drawable文件,如果您已经将其更改为小写,如果您使用的是选择器xml文件,那么检查您在这些文件中链接的其他文件。所有的都应该是小写的。

  2. Go to java files which show error and remove IMPORT R.java file from imports list.

    转到显示错误并删除导入R的java文件。来自导入列表的java文件。

  3. Go to Projects>>Clean.

    去项目> >清洁。

This should fix the problem. This is how i fixed :)

这应该能解决问题。这是我固定的方式:)

#8


0  

My issue was that I had android:orientation misspelled in my activity_main.xml file and I was getting this error. I fixed the spelling and problem went away! So make sure activity_main.xml doesn't have any errors in it.

我的问题是,我有android:在我的activity_main中定位错误。xml文件,我得到了这个错误。我修正了拼写和问题。所以要确保activity_main。xml中没有任何错误。

#9


0  

Sometimes when you extract your file it miss some part so better when its extracting make sure all file are extracting properly and then run eclipse after that run a simple file and install plugin of avd it helped in my case

有时,当您提取文件时,它会忽略某些部分,当它的提取确保所有文件都正确提取,然后运行eclipse之后,运行一个简单的文件并安装avd插件,这对我的情况很有帮助。

#10


-1  

if the problem persists then try closing the other projects by

如果问题持续存在,那么尝试关闭其他项目。

right click -> close Unrelated projects !

右击->关闭不相关的项目!

this worked in my case

这在我的案例中起作用。

#11


-1  

For eclipse users: Comment the lines including R.* Clean and build. R.java will be generated and then uncomment the R.* and rebuild.

对于eclipse用户:注释包含R的行。*清洁和构建。R。将生成java,然后取消对R的注释。*和重建。

#12


-2  

the best solution for r.java missing for linux... R.java is self generated in gen folder.. so better dont edit or create manually by urself ..

r的最佳解。java失踪linux……R。java是在gen文件夹中生成的self。所以最好不要自行编辑或手动创建。

-open terminal(alt + ctrl + t) -change directory to skd->tools -then provide executive attribute to all executable file by(sudo chmod +x filename) -do the same for files in sdk->platform tools .. (ie sudo chmod +x filename) .. -----every executable file sud b provided with +x attribute...

-打开终端(alt + ctrl + t) -更改目录到skd->工具-然后向所有可执行文件提供执行属性(sudo chmod +x文件名)-对sdk->平台工具中的文件执行相同的操作。(sudo chmod +x文件名)..---每个可执行文件sud b提供+x属性…

#13


-2  

just delete gen folder all of your error will be cleared

删除gen文件夹,所有的错误将被清除。

#14


-2  

Proven successful method, check the file (AndroidManifest.xml) and delete all comments in it, and make sure there are no errors in this file, I tried and did work with me.

验证成功的方法,检查文件(AndroidManifest.xml)并删除其中的所有注释,并确保在这个文件中没有错误,我尝试了并与我一起工作。

#1


172  

After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools. Eclipse提供错误,缺少R。java文件在最近更新后。

第一次更新到SDK工具后,您可能需要重新启动Android SDK管理器并安装一个新项目:Android SDK构建工具。

After installing this, clean your projects and rebuild.

安装完毕后,清理您的项目并进行重建。

#2


6  

Yesterday, I made an update with sdk manager, and I had the same problem as you. I fixed the issue: I have updated another time the android sdk (with the sdk manager tool), then I check update from eclipse for install the updated ADT plugin and I rebuid my project. "Android sdk Build-tools" from Android sdk manager is now rev 17 and now it is OK. I think the issue is from adt plugin from eclipse

昨天我和sdk经理做了一个更新,我遇到了和你一样的问题。我修正了这个问题:我已经更新了另一次android sdk(使用sdk管理器工具),然后我检查eclipse的更新,以便安装更新的ADT插件,并且我还拒绝了我的项目。Android sdk管理器的Android sdk构建工具现在是rev 17,现在可以了。我认为这个问题来自于eclipse的adt插件。

#3


2  

import android.R - remove this statement from all your classes and then do a clean your R file will be generated. if this did not work then check all your xml files for any errors and then do a clean. These 2 are the most common reasons for R file to go missing

导入安卓。从所有的类中删除该语句,然后生成一个干净的R文件。如果没有工作,那么检查所有的xml文件是否有错误,然后进行清理。这两个是R文件丢失的最常见原因。

#4


1  

Changes in your Build target also can effect R.java in Eclipse so

您的构建目标的更改也可以影响R。java在Eclipse中所以

Right Click Project >> Properties >> Android >> Select Latest(usually) Android API Platform >> Click OK

右键点击项目>>属性>> >> >选择最新(通常)Android API平台>>点击确定。

Hope this is helpful.

希望这是有帮助的。

#5


1  

Follow These steps...

遵循以下步骤……

  1. Right Click Your Project.
  2. 右键单击您的项目。
  3. Select Properties->Android Check Project Build Target and API Level.
  4. 选择属性->Android检查项目构建目标和API级别。
  5. Again come back and open Android Sdk Manager Chekc the Tools and make sure you are installed Curresponding Android SDK Build Tools.
  6. 再次回来,打开Android Sdk管理器Chekc工具,确保您已经安装了curresponse Android Sdk构建工具。

Eg : IF you selected api level 17 in properties you should install Android SDK Build Tools 17..

如果你选择了api级别17的属性,你应该安装Android SDK构建工具17..

#6


0  

Try this:

试试这个:

  1. make a backup of your projects on desktop

    在桌面上备份你的项目。

  2. close eclipse

    关闭eclipse

  3. delete your workspace

    删除您的工作区

  4. restart eclipse and import your projects again.

    重新启动eclipse并再次导入您的项目。

#7


0  

I had same problem.. I solved by doing the following:

我有同样的问题。我解决了以下问题:

  1. check all xml files and drawable files if there are any CAPITAL LETTERS in file name, if you have then change it to lower case, if you are using selector xml files then check the other files you are linking in those files..all should be lower case.

    如果文件名称中有大写字母,请检查所有的xml文件和drawable文件,如果您已经将其更改为小写,如果您使用的是选择器xml文件,那么检查您在这些文件中链接的其他文件。所有的都应该是小写的。

  2. Go to java files which show error and remove IMPORT R.java file from imports list.

    转到显示错误并删除导入R的java文件。来自导入列表的java文件。

  3. Go to Projects>>Clean.

    去项目> >清洁。

This should fix the problem. This is how i fixed :)

这应该能解决问题。这是我固定的方式:)

#8


0  

My issue was that I had android:orientation misspelled in my activity_main.xml file and I was getting this error. I fixed the spelling and problem went away! So make sure activity_main.xml doesn't have any errors in it.

我的问题是,我有android:在我的activity_main中定位错误。xml文件,我得到了这个错误。我修正了拼写和问题。所以要确保activity_main。xml中没有任何错误。

#9


0  

Sometimes when you extract your file it miss some part so better when its extracting make sure all file are extracting properly and then run eclipse after that run a simple file and install plugin of avd it helped in my case

有时,当您提取文件时,它会忽略某些部分,当它的提取确保所有文件都正确提取,然后运行eclipse之后,运行一个简单的文件并安装avd插件,这对我的情况很有帮助。

#10


-1  

if the problem persists then try closing the other projects by

如果问题持续存在,那么尝试关闭其他项目。

right click -> close Unrelated projects !

右击->关闭不相关的项目!

this worked in my case

这在我的案例中起作用。

#11


-1  

For eclipse users: Comment the lines including R.* Clean and build. R.java will be generated and then uncomment the R.* and rebuild.

对于eclipse用户:注释包含R的行。*清洁和构建。R。将生成java,然后取消对R的注释。*和重建。

#12


-2  

the best solution for r.java missing for linux... R.java is self generated in gen folder.. so better dont edit or create manually by urself ..

r的最佳解。java失踪linux……R。java是在gen文件夹中生成的self。所以最好不要自行编辑或手动创建。

-open terminal(alt + ctrl + t) -change directory to skd->tools -then provide executive attribute to all executable file by(sudo chmod +x filename) -do the same for files in sdk->platform tools .. (ie sudo chmod +x filename) .. -----every executable file sud b provided with +x attribute...

-打开终端(alt + ctrl + t) -更改目录到skd->工具-然后向所有可执行文件提供执行属性(sudo chmod +x文件名)-对sdk->平台工具中的文件执行相同的操作。(sudo chmod +x文件名)..---每个可执行文件sud b提供+x属性…

#13


-2  

just delete gen folder all of your error will be cleared

删除gen文件夹,所有的错误将被清除。

#14


-2  

Proven successful method, check the file (AndroidManifest.xml) and delete all comments in it, and make sure there are no errors in this file, I tried and did work with me.

验证成功的方法,检查文件(AndroidManifest.xml)并删除其中的所有注释,并确保在这个文件中没有错误,我尝试了并与我一起工作。