Eclipse / Android:“在项目中运行构建器‘Android预编译器’的错误…”

时间:2022-04-17 10:32:47

Attempting to do some work on an Android project I haven't worked on for a couple of months, yet every time I attempt to build the project Eclipse throws up a dialog saying:

尝试在一个我几个月没做过的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

I'm running Eclipse on a Mac with an Android project build target 4.0.3 (API Level 15) and I've the following versions of things installed

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

  • Eclipse - 3.7.2
  • Eclipse - 3.7.2章
  • Android Development Tools - 21.0.1
  • Android开发工具——21.0.1
  • Android SDK - up to 17
  • Android SDK——最多17个。

I've already tried a few things, like starting a whole new workspace, installing this 'Subversive SVN JDT Ignore Extensions', upgrading everything, making sure I don't have any files without extensions in my source folder (or anywhere else), ensuring my Java compiler is 1.6 and switching it off and on again.

我已经尝试了一些东西,就像开始一个全新的工作空间,安装这个颠覆性的SVN JDT忽略扩展,升级,确保我没有任何文件没有扩展源文件夹(或其他地方),确保我的Java编译器1.6和切换又断断续续。

EDIT

编辑

Here's the stack trace from the Eclipse error log for this problem:

下面是来自这个问题的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)

And the session data:

和会话数据:

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

ANOTHER EDIT

另一个编辑

OK, so more searching led me to this page, which suggests that this issue is definitely related to the presence of files without an extension in my project - however I don't know which file and for the life of me I can't find any in that project!

好的,所以更多的搜索引导我到这个页面,这表明这个问题肯定与我的项目中没有扩展名的文件的存在有关——但是我不知道是哪个文件,而且我在那个项目中也找不到任何文件!

I'd even be happy if someone could explain what this error means and how I might get more debug info about the underlying error.

如果有人能解释这个错误是什么意思,以及我如何能得到关于底层错误的更多调试信息,我甚至会很高兴。

11 个解决方案

#1


107  

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

对于那些不希望安装ADT预览版的用户,这里有一个解决方案。

  1. Open properties of project in Eclipse then Resources -> Resource filters.
  2. 在Eclipse中打开项目的属性,然后是资源——>资源过滤器。
  3. Click the "Add..." button -> Check "Exclude all", "Files and folders", "All children". In the text entry box input ".svn" (without quotes).
  4. 点击“添加…”按钮- >检查“排除”,“文件和文件夹”,“所有的孩子”。在文本输入框中输入”。svn”(没有引号)。
  5. Restart Eclipse.
  6. 重新启动Eclipse。

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

.文件夹我有同样的问题,工作就像一个魅力。

#2


84  

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.

ADT工具的21.0.1版本有一个错误,如果您有任何没有扩展名的文件,它会阻止项目构建。对于使用subversion的用户(比如我)来说,这是一个特别的问题,因为subversion的文件没有扩展。

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).

一个建议的解决方案是安装这些颠覆性的Eclipse插件(Help > >安装新软件的工作与您的Eclipse版本网站>扩大“协作”>选择“颠覆性的SVN JDT忽略扩展”和“颠覆性的SVN团队提供者”),但这对我没用(我在靛蓝,也许在朱诺作品)。

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.

解决方案是在谷歌安装ADT工具和SDK管理器的21.1预览版。在这里可以找到清晰的说明,你可以阅读所有的背景,给愤怒的开发者们添加你的声音。

#3


15  

I just restarted Eclipse and the problem got solved.

我刚刚重启Eclipse,问题就解决了。

#4


9  

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.

我也有同样的问题,我意识到我已经关闭了另一个与我正在建设的项目有关的项目。我一打开它,一切都消失了。

#5


2  

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

可能你有关闭的“appcompact_v7”库来创建新的文件。这就解决了我的问题

#6


1  

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

我遇到这个错误,删除了所有.svn文件,我的项目无法工作,当进程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,

我发现这是我的项目中的一个空的res dir,我不知道它是怎么回事,但是当删除这个空的res dir时,我的项目workd,

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

因此,您应该检查项目中的所有文件。

#7


1  

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.

我也面临着同样的问题,浪费了很多时间来解决这个问题,而且上面给出的解决方案对我来说并不适用。我通过使用Eclipse ->帮助->检查更新来解决这个问题,然后在更新完成后重新启动Eclipse。

#8


1  

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.

如果您不小心关闭了运行项目所需的库项目,那么只需在eclipse中打开它们。这个错误必须消失。

#9


0  

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

另一种情况:我关闭了当前的项目(使用构建错误消息),丢弃了正在使用的SVN存储库,重新编译:

Building error

构建错误

I add the repository location:

我添加了存储库位置:

Building ok!

建立好的!

#10


0  

For solving this issue I need to run eclipse as administrator

为了解决这个问题,我需要运行eclipse作为管理员。

#11


-1  

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.

我最近遇到了这个问题,上面给出的解决方法对我不起作用。我没有任何文件没有扩展名。在从现有代码中添加一个新项目之后,出现了一个设置错误,这似乎使eclipse的状态变得混乱。之后,我试图清理或构建的工作空间中的任何项目都会在java.lang.NullPointerException中给出Android预编译错误。

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.

我找到了主。在/res目录内的xml文件由于某种原因没有被找到,即使该文件非常多。解决方案是关闭Eclipse Java编辑面板中所有打开的文件透视图,关闭所有项目,然后打开项目并打开主xml文件。在我这样做之后,预编译器问题就消失了。

#1


107  

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

对于那些不希望安装ADT预览版的用户,这里有一个解决方案。

  1. Open properties of project in Eclipse then Resources -> Resource filters.
  2. 在Eclipse中打开项目的属性,然后是资源——>资源过滤器。
  3. Click the "Add..." button -> Check "Exclude all", "Files and folders", "All children". In the text entry box input ".svn" (without quotes).
  4. 点击“添加…”按钮- >检查“排除”,“文件和文件夹”,“所有的孩子”。在文本输入框中输入”。svn”(没有引号)。
  5. Restart Eclipse.
  6. 重新启动Eclipse。

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

.文件夹我有同样的问题,工作就像一个魅力。

#2


84  

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.

ADT工具的21.0.1版本有一个错误,如果您有任何没有扩展名的文件,它会阻止项目构建。对于使用subversion的用户(比如我)来说,这是一个特别的问题,因为subversion的文件没有扩展。

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).

一个建议的解决方案是安装这些颠覆性的Eclipse插件(Help > >安装新软件的工作与您的Eclipse版本网站>扩大“协作”>选择“颠覆性的SVN JDT忽略扩展”和“颠覆性的SVN团队提供者”),但这对我没用(我在靛蓝,也许在朱诺作品)。

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.

解决方案是在谷歌安装ADT工具和SDK管理器的21.1预览版。在这里可以找到清晰的说明,你可以阅读所有的背景,给愤怒的开发者们添加你的声音。

#3


15  

I just restarted Eclipse and the problem got solved.

我刚刚重启Eclipse,问题就解决了。

#4


9  

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.

我也有同样的问题,我意识到我已经关闭了另一个与我正在建设的项目有关的项目。我一打开它,一切都消失了。

#5


2  

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

可能你有关闭的“appcompact_v7”库来创建新的文件。这就解决了我的问题

#6


1  

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

我遇到这个错误,删除了所有.svn文件,我的项目无法工作,当进程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,

我发现这是我的项目中的一个空的res dir,我不知道它是怎么回事,但是当删除这个空的res dir时,我的项目workd,

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

因此,您应该检查项目中的所有文件。

#7


1  

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.

我也面临着同样的问题,浪费了很多时间来解决这个问题,而且上面给出的解决方案对我来说并不适用。我通过使用Eclipse ->帮助->检查更新来解决这个问题,然后在更新完成后重新启动Eclipse。

#8


1  

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.

如果您不小心关闭了运行项目所需的库项目,那么只需在eclipse中打开它们。这个错误必须消失。

#9


0  

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

另一种情况:我关闭了当前的项目(使用构建错误消息),丢弃了正在使用的SVN存储库,重新编译:

Building error

构建错误

I add the repository location:

我添加了存储库位置:

Building ok!

建立好的!

#10


0  

For solving this issue I need to run eclipse as administrator

为了解决这个问题,我需要运行eclipse作为管理员。

#11


-1  

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.

我最近遇到了这个问题,上面给出的解决方法对我不起作用。我没有任何文件没有扩展名。在从现有代码中添加一个新项目之后,出现了一个设置错误,这似乎使eclipse的状态变得混乱。之后,我试图清理或构建的工作空间中的任何项目都会在java.lang.NullPointerException中给出Android预编译错误。

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.

我找到了主。在/res目录内的xml文件由于某种原因没有被找到,即使该文件非常多。解决方案是关闭Eclipse Java编辑面板中所有打开的文件透视图,关闭所有项目,然后打开项目并打开主xml文件。在我这样做之后,预编译器问题就消失了。