[英]Intellij IDEA 14 - Package R does not exist
Well, I recognize that this has been asked before, but in browsing the other answers: 好吧,我知道以前曾经问过,但是在浏览其他答案时:
IntelliJ IDEA - Can't build anything, always get "package R does not exist" IntelliJ IDEA - 无法构建任何东西,总是得到“包R不存在”
Error: java: package R does not exist 错误:java:包R不存在
etc. 等等
none of the solutions work. 没有一个解决方案有效。
This is for a project that was building fine until at least the last couple days, so whatever is causing the problem must be new. 这是一个项目,至少在过去的几天里建设正常,所以无论造成什么问题都必须是新的。
Symptoms: 症状:
Attempting to to a Build > Rebuild Project fails. 尝试构建>重建项目失败。 I see the step for compiling generates sources go by in the status bar, but the next compilation step fails with the dreaded "java: package R does not exist." 我在状态栏中看到编译生成源的步骤,但下一个编译步骤失败,可怕的“java:包R不存在”。
R is found just fine in the IDE, so only compilation fails, suggesting there is a problem with the compilation of the generated sources. 在IDE中发现R很好,因此只有编译失败,这表明编译生成的源存在问题。 This seems borne out by the fact that in the out/production/[module] directory, only some resource files show up, no compiled classes, nothing in the "generated" sbupackage, a no apk file. 这似乎证明了在out / production / [module]目录中,只显示了一些资源文件,没有编译的类,没有“生成”的sbupackage,没有apk文件。
Interestingly, when I connect my phone to the computer and try running the application on the device, new changes are picked up, so something is being successfully built somewhere. 有趣的是,当我将手机连接到计算机并尝试在设备上运行应用程序时,会发现新的更改,因此某些地方正在成功构建某些内容。
Things I've tried: 我试过的事情:
Per the other threads I've tried: 根据我尝试的其他线程:
The only recent changes in xml were: xml最近唯一的变化是:
So at this point I'm out of ideas. 所以在这一点上我没有想法。 Sorry to rehash a somewhat common question. 很抱歉重新提出一个有点常见的问题。
I have the same problem and it definitely related to last update of the IDE. 我有同样的问题,它肯定与IDE的上次更新有关。 My version is IU-139.1117.1 Before the update Build -> 'Rebuild Project' was working ok in a windows and a mac installation of the IDE. 我的版本是IU-139.1117.1更新之前Build - >'Rebuild Project'在Windows的Windows和mac安装中运行正常。 I updated windows first and 'Rebuild Project' shows the error 'Package R does not exist' even for a new Android project. 我首先更新了Windows,并且'Rebuild Project'显示错误'Package R不存在',即使对于新的Android项目也是如此。 Same error apeared in mac installation imediately after the update. 在更新后立即在mac安装中出现相同的错误。 'Make project', 'Make module' and 'Compile' commands on the Build menu are all working ok with no error only 'Rebuild project' raises the error. “生成项目”,“生成模块”和“编译”命令在“生成”菜单上都正常工作,没有错误“重建项目”引发错误。 For a new Gradle Android project everything works ok. 对于新的Gradle Android项目,一切正常。 It seems something is wrong with last update. 上次更新似乎有问题。
It is reported issue in IDEA 14.0.3 ( http://youtrack.jetbrains.com/issue/IDEA-135234 ). 据报道,IDEA 14.0.3( http://youtrack.jetbrains.com/issue/IDEA-135234 )中存在问题。
You can try to Compile Module (Ctrl-Shift-F9)
for the module that contains missing R file. 您可以尝试Compile Module (Ctrl-Shift-F9)
包含缺少R文件的模块的Compile Module (Ctrl-Shift-F9)
。 It works for me (but I have to do this every time i add/remove items in resources). 它适用于我(但每次我添加/删除资源中的项目时我都必须这样做)。
不要使用Rebuild Project,使用Make Project并刷新你的项目,也许你应该多试几次。
Try File | 试试文件| Invalidate Caches. 使缓存无效。 This is solve my problem. 这是解决我的问题。
If you cannot wait for a officially stable build, install IDEA EAP 14.0.4 (IntelliJ IDEA 14.0.4 EAP build 139.1408, released on February 20th, 2015) from https://confluence.jetbrains.com/display/IDEADEV/IDEA+14+EAP 如果您不能等待正式稳定版本,请从https://confluence.jetbrains.com/display/IDEADEV/IDEA+安装IDEA EAP 14.0.4(IntelliJ IDEA 14.0.4 EAP build 139.1408,于2015年2月20日发布) 14 + EAP
I've just solved all issues and rebuild project works again. 我刚刚解决了所有问题并重新开始了项目工作。
解决了智能IDEA的14.1更新,现已上市。
I had the same issue on a Windows 7 box today with a Java 7 Gradle project, using IntelliJ 14.1.5. 我今天在使用IntelliJ 14.1.5的Java 7 Gradle项目的Windows 7机箱上遇到了同样的问题。
The problem was that somehow the classpath was "too long", but IntelliJ gave me only those strange "java: package foo does not exist" compile error's. 问题是,类路径不知何故“太长了”,但IntelliJ只给了我那些奇怪的“java:package foo不存在”编译错误。
The usual tricks (see also above) did not help. 通常的技巧(见上文)没有帮助。
The workaround was to shorten the classpath a bit, in my case setting GRADLE_USER_HOME to c:/.gradle (was before c:/users/myusername/.gradle). 解决方法是缩短类路径,在我的例子中将GRADLE_USER_HOME设置为c:/。gradle(在c:/users/myusername/.gradle之前)。 After resyncing the gradle project everything worked fine. 重新启动gradle项目后一切正常。
The problem was therefor obviously IMO some kind of windows filesystem path length restriction. 问题是因为显然IMO某种Windows文件系统的路径长度限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.