Eclipse/Android: “在项目上运行构建器‘ Android Pre Compiler’时出现错误... ...”

尝试在一个我已经有几个月没有做过的 Android 项目上做一些工作,但是每次我尝试构建这个项目时,Eclipse 都会弹出一个对话框说:

'Building workspace' has encountered a problem


Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'XXX'
java.lang.NullPointerException

我在 Mac 上运行 Eclipse,Android 项目构建目标为4.0.3(API 级别15) ,我已经安装了以下版本的软件

  • Eclipse-3.7.2
  • Android 开发工具 -21.0.1
  • Android SDK-最多17个

我已经尝试了一些事情,比如启动一个全新的工作区,安装这个“颠覆性 SVN JDT 忽略扩展”,升级所有东西,确保我的源文件夹(或其他任何地方)中没有没有扩展的文件,确保我的 Java 编译器是1.6,并关闭和打开它。

剪辑

下面是 Eclipse 错误日志中关于这个问题的堆栈跟踪:

java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder.build(PreCompilerBuilder.java:673)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:513)
at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:432)
at org.eclipse.ui.actions.BuildAction$1.runInWorkspace(BuildAction.java:305)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

还有会话数据:

eclipse.buildId=M20120208-0800
java.version=1.6.0_37
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -keyring /Users/onemick/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -data /Projects/_EclipseWorkspace -keyring /Users/onemick/.eclipse_keyring -showlocation

另一个编辑

好吧,所以更多的搜索引导我到 这一页,这表明这个问题肯定与我的项目中没有扩展的文件的存在有关——然而我不知道是哪个文件,我的生活中我无法在那个项目中找到任何文件!

如果有人能够解释这个错误的含义以及如何获得更多关于底层错误的调试信息,我甚至会很高兴。

91179 次浏览

I always hate answering my own questions, but this is a genuine solution.

The 21.0.1 version of the ADT tools has a bug that prevents a project building if you have any files without extensions in them. This is a particular problem for users (like me) using subversion with has extension-less files.

One recommended solution is to install these 'subversive' Eclipse plugins (Help > Install new Software > Work with your Eclipse version site > Expand 'Collaboration' > Choose 'Subversive SVN JDT Ignore Extensions' and 'Subversive SVN Team Provider') but this didn't work for me (I'm on Indigo, perhaps on Juno it works).

The solution is to install the 21.1 preview version of the ADT tools and SDK manager from Google. Clear instructions can be found here and you can read all the background add your voice to the angry mob of developers here.

For those of you who don't want to install preview version of ADT, there is a workaround described here.

  1. Open properties of project in Eclipse then Resources -> Resource filters.
  2. Click the "Add..." button -> Check "Exclude all", "Files and folders", "All children". In the text entry box input ".svn" (without quotes).
  3. Restart Eclipse.

I had the same problem with .git folder, it worked like a charm.

Another case: I closed the current project (with building error message), discarded the SVN repository in use, recompile:

Building error

I add the repository location:

Building ok!

I meet this error,and delete all .svn file, my project can't work,when process 55%

and I find this is an empty res dir in my project,I don't know how it coms,but when delete the empty res dir,my project workd,

so,you should check all your files in your project.

i encountered this problem recently and the solutions given above did not work for me. i did not have any files without extensions. It so happened that after adding a new project from existing code, there was a setup error that seems to have messed up the state of eclipse. After that, any project in the workspace that i tried to clean or build was giving the Android Pre-Compiler error with the java.lang.NullPointerException.

i found that the main.xml files inside /res directory was for some reason not being found, even though the file was very much there. Solution was to close all open file perspectives in the Eclipse Java Edit Panel, close all projects, then open project and open the main xml file. After i did that, the Pre-Compiler problem went away.

I just restarted Eclipse and the problem got solved.

I was also facing the same issue, and wasted a lot of time fixing this, also the above given solutions doesn't work for me. I solved this problem by going to Eclipse -> Help -> Check for updates, and then restarting eclipse after update finished.

I also had the same problem and i realised that i had closed another project that was connected with the one I was building. Once i opened it everything disappeared.

If you have accidentally closed the library projects that are essential for running your project then just open them in eclipse. This error must vanish.

May be you have close 'appcompact_v7' library to create new file. this solved my problem by open it back

For solving this issue I need to run eclipse as administrator