迫使想法产生R的最简单的方法是什么?Java文件吗?

时间:2021-03-14 04:29:07

I am trying to run Android sample applications using intellij idea and R.Java file is missing form notepad samples source directory.

我正在尝试使用intellij idea和R来运行Android示例应用程序。Java文件缺少notepad示例源目录。

9 个解决方案

#1


5  

Make sure you have a gen folder in your project root. If you don't, make one yourself.

确保在项目根目录中有gen文件夹。如果你不喜欢,自己做一个。

#2


15  

Make sure you have the right settings: project structure -> Facets -> Android -> yourproject -> compiler

确保您有正确的设置:项目结构-> facet -> Android -> yourproject ->编译器

Check compile resources by IDE and Regenerate R.java when resources are changed.

使用IDE检查编译资源并重新生成R。当资源被改变时,java。

This stole most of my morning, hopefully I'll save someone else some time:)

这几乎占据了我整个上午的时间,希望我可以为别人节省一些时间。

#3


4  

Use Build | Make. Actually, IDEA generates R.java file automatically every time you make a change in any XML file under the /res directory.

使用构建|。事实上,想法生成R。每次在/res目录下的任何XML文件中进行更改时,java文件都会自动执行。

UPDATE: /gen directory must be present in the project and also configured as a Source root in IDEA module so that it can resolve the IDs in your source code.

更新:/gen目录必须出现在项目中,并在IDEA模块中配置为源根目录,以便在源代码中解析id。

#4


1  

Build -> Compile 'R.java'

构建- >编译“参数”

or simply Ctrl+Shift+F9.

或者Ctrl + Shift + F9。

#5


1  

Pay attention that, in current version of IDEA 12, the by-design behaviour is not to generate R.java in the generated sources project directory, but in an IDEA's system directory:

注意,在当前版本的IDEA 12中,副设计行为不是生成R。java在生成的源代码项目目录中,但在IDEA的系统目录中:

http://youtrack.jetbrains.com/issue/IDEA-99045

http://youtrack.jetbrains.com/issue/idea - 99045

"It is behaviour of IDEA 12, it doesn't generate full R.java in gen folder, it generates it in the IDEA's system dir during compilation."

这是想法12的行为,它不会产生完全的R。java在gen文件夹中,它在编译期间在IDEA的system dir中生成。

They intend to change this confusing behaviour, but if you're currently working in IDEA 12, look into ~/.IntelliJIdea12\system\compiler\YOUR_PROJECT_NAME.RANDOM_STRING\.generated\aapt\YOUR_PROJECT_NAME.RANDOM_STRING\production\package\R.java for the actual generated source file.

他们想要改变这种令人困惑的行为,但是如果你正在构思12,请查看~/. intellijidea12 \系统编译器\YOUR_PROJECT_NAME.RANDOM_STRING\.generated\aapt\你的_project_name . random_string \生产\package\程序包\R。java用于实际生成的源文件。

#6


0  

Fix all errors appear on .xml files. R.java will be re-appeared

修正所有出现在.xml文件上的错误。R。java将陆战队员

#7


0  

Also make sure to check your imports. Sometimes when your IDE (eclipse & intellij as well) cannot find your generated R class and auto-imports android.R.

还要确保检查您的导入。有时,当您的IDE (eclipse & intellij)无法找到生成的R类并自动导入android.R。

import android.R kills everything you are doing in your generated sources!

导入安卓。R杀死你在生成的资源中所做的一切!

Cost me 30min of my life...

花了我30分钟的时间……

#8


0  

In AndroidStudio use: Build -> Rebuild Project.

在AndroidStudio中使用:Build ->重建项目。

And remember, the generated R file is not in the project "gen" directory. It is in the "out" directory (drill down to your project).

记住,生成的R文件不在项目“gen”目录中。它在“out”目录中(深入到您的项目)。

#9


0  

If you are using IDEA 12 on Windows 7 (and probably Vista and 8), R.Java can be found at :

如果你在Windows 7(可能还有Vista和8)上使用IDEA 12,那么R。Java可在以下网址找到:

C:\Users\[username]\.IdeaIC12\system\compiler\[project].nnnnnnnn\.generated\aapt\[project].nnnnnnnn\production\[your\name\space]\R.java 

#1


5  

Make sure you have a gen folder in your project root. If you don't, make one yourself.

确保在项目根目录中有gen文件夹。如果你不喜欢,自己做一个。

#2


15  

Make sure you have the right settings: project structure -> Facets -> Android -> yourproject -> compiler

确保您有正确的设置:项目结构-> facet -> Android -> yourproject ->编译器

Check compile resources by IDE and Regenerate R.java when resources are changed.

使用IDE检查编译资源并重新生成R。当资源被改变时,java。

This stole most of my morning, hopefully I'll save someone else some time:)

这几乎占据了我整个上午的时间,希望我可以为别人节省一些时间。

#3


4  

Use Build | Make. Actually, IDEA generates R.java file automatically every time you make a change in any XML file under the /res directory.

使用构建|。事实上,想法生成R。每次在/res目录下的任何XML文件中进行更改时,java文件都会自动执行。

UPDATE: /gen directory must be present in the project and also configured as a Source root in IDEA module so that it can resolve the IDs in your source code.

更新:/gen目录必须出现在项目中,并在IDEA模块中配置为源根目录,以便在源代码中解析id。

#4


1  

Build -> Compile 'R.java'

构建- >编译“参数”

or simply Ctrl+Shift+F9.

或者Ctrl + Shift + F9。

#5


1  

Pay attention that, in current version of IDEA 12, the by-design behaviour is not to generate R.java in the generated sources project directory, but in an IDEA's system directory:

注意,在当前版本的IDEA 12中,副设计行为不是生成R。java在生成的源代码项目目录中,但在IDEA的系统目录中:

http://youtrack.jetbrains.com/issue/IDEA-99045

http://youtrack.jetbrains.com/issue/idea - 99045

"It is behaviour of IDEA 12, it doesn't generate full R.java in gen folder, it generates it in the IDEA's system dir during compilation."

这是想法12的行为,它不会产生完全的R。java在gen文件夹中,它在编译期间在IDEA的system dir中生成。

They intend to change this confusing behaviour, but if you're currently working in IDEA 12, look into ~/.IntelliJIdea12\system\compiler\YOUR_PROJECT_NAME.RANDOM_STRING\.generated\aapt\YOUR_PROJECT_NAME.RANDOM_STRING\production\package\R.java for the actual generated source file.

他们想要改变这种令人困惑的行为,但是如果你正在构思12,请查看~/. intellijidea12 \系统编译器\YOUR_PROJECT_NAME.RANDOM_STRING\.generated\aapt\你的_project_name . random_string \生产\package\程序包\R。java用于实际生成的源文件。

#6


0  

Fix all errors appear on .xml files. R.java will be re-appeared

修正所有出现在.xml文件上的错误。R。java将陆战队员

#7


0  

Also make sure to check your imports. Sometimes when your IDE (eclipse & intellij as well) cannot find your generated R class and auto-imports android.R.

还要确保检查您的导入。有时,当您的IDE (eclipse & intellij)无法找到生成的R类并自动导入android.R。

import android.R kills everything you are doing in your generated sources!

导入安卓。R杀死你在生成的资源中所做的一切!

Cost me 30min of my life...

花了我30分钟的时间……

#8


0  

In AndroidStudio use: Build -> Rebuild Project.

在AndroidStudio中使用:Build ->重建项目。

And remember, the generated R file is not in the project "gen" directory. It is in the "out" directory (drill down to your project).

记住,生成的R文件不在项目“gen”目录中。它在“out”目录中(深入到您的项目)。

#9


0  

If you are using IDEA 12 on Windows 7 (and probably Vista and 8), R.Java can be found at :

如果你在Windows 7(可能还有Vista和8)上使用IDEA 12,那么R。Java可在以下网址找到:

C:\Users\[username]\.IdeaIC12\system\compiler\[project].nnnnnnnn\.generated\aapt\[project].nnnnnnnn\production\[your\name\space]\R.java