新建Android工程报错:'Building workspace' has encountered a problem...解决办法

来源:互联网 发布:松下fpwin编程手册 编辑:程序博客网 时间:2024/06/05 06:27

Eclipse新建工程报错: ‘Building workspace’ has encountered a problem. Errors occured during the build.解决办法。

问题

公司所谓的培训了三个周末的Android之后,本周末,要考试。。。
晚上,看了会儿书,然后准备写个程序熟悉一下,打开eclipse adt,新建——Android project,一路往下,都没有问题,可是在点了 finish之后,就特么报错了,’Building workspace’ has encountered a problem. Errors occured during the build.
Errors running builder ‘Android Resource Manager’ on project ‘test1’.
java.lang.NullPointerException.
如下图:
报错截图
真是日了狗了,构建工作空间发生错误….空指针异常,真是见了鬼了,然后我尝试了很多方法,各种百度,(百度到的都是一些扯淡的东西,想Google,可是上不去,这个电脑上还没有记Google得镜像地址,无奈。。。)。
尝试的方法:
1、重新解压了一个Eclipse ADT,然,并没有什么卵用。
2、删除workspace的 .metadate文件
3、删除 /.android ,也没有什么用处
4、打开SDK Manager,update,可是速度让人心碎。。。。
……..
and so on


解决办法

最后找到一个博客,博主贴了一段从stackoverflow上一段话:
如下:I spent the whole day just trying to create a simple Android Application Project on my Mac (10.7.5). When pressing “Finish” in the project wizard, I got the following error message:

Errors occurred during the build.Errors running builder 'Android Resource Manager' on project 'MyFirstApp'.java.lang.NullPointerException

A project with empty directories was created, but no files were generated except for a file called “proguard-project.txt”, which just contained comments.

I literally just downloaded the ADT Bundle onto my Mac.

I’ve already had a look at here and tried all the suggestions there, like removing the “.metadata” folder and trying to change the Android “Project Build Target”.

I’ve also tried using Eclipse Juno and Kepler - same problem. I’ve reinstalled Eclipse and recreated workspaces many many times.

So I’m pretty stuck…it’s not working out of the box. Any help would be most appreciated.

Sounds like Eclipse doesn’t see SDK Android folder. Did you configured your Eclipse? – Maxim ShoustinAug 7 ‘13 at 6:42

I didn’t think I need to? ADT Bundle comes with the SDK installed. I had a look at the “Eclipse/Preferences/Android”, and it seems to be pointing to the “SDK” directory that came with the bundle “adt-bundle-mac-x86_64-20130729” – iht Aug 7 ‘13 at 6:49

Lots of people solved this issue as described at this link: stackoverflow.com/questions/14455018/… – superpuccio Oct 2 ‘13 at 8:55

Were you able to solve this problem? I have same issue and I can’t find any reason why this is happening. – Sourabh86 May 13 ‘14 at 14:02

18
down vote
I got same error on my windows machine.

When I compared project file system with other working project I found that

project.properties
was missing, So I Created a txt file and renamed it to “project.properties” then got this message on my console.

“Project has no project.properties file! Edit the project properties to set one”
Then I went through project menu

project->properties->android->choose & set the “project build target”.
then build it.now everything was smooth.

We just setup a valid project.properites file for that project.

3
down vote
This is the the solution I’ve used to solve that problem which gave me enough troubles.

Make sure that you’ve installed already the following libraries Android Support Library, Android Support Repository and Google Repository by checking in the Extra folder by openning the Android SDK Manager in eclipse.
Create an Android Sample Project then choose the appcompact_v7 library.
Close the project you’ve just created, restart Eclipse and create now a new Android Application project.
Hope that it will help you !

I followed following article and it solved the problem by adding a line to the Eclipse.ini

To resolve the issue, do the following:

  1. Go to your eclipse directory and find “Eclipse.app” file. Just to
    be on safe side, back up this file somewhere (Just the Eclipse.app file).
  2. Right-Click on “Eclipse.app” file, and select “Show Package
    Contents”
  3. Once inside package, go to Contents–>MacOS, and open
    “eclipse.ini”
  4. Just before the “-vmargs”, add the following:

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java

  1. Run eclipse again, and you should be able to create the project
    without any problems.

和我遇到的情况完全符合,特么的,又是JDK版本的问题。
So…..
我很好奇,我的mac里有没有/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java这个文件,于是…
one
这里写图片描述

然后,就尝试修改Eclipse的ini配置文件了
这里写图片描述
这里写图片描述
这里写图片描述

Jdk 1.6,Jdk1.7我都安装了,只是默认的是1.7
这里写图片描述
7月下旬刚到项目组的时候,从SVN上检出项目组的项目(Web项目),然后就我的mac遇到了jdk版本的问题,当时我只安装了jdk1.7,为了跑起公司的项目,从网上找了个jdk1.6装上,在eclipse的偏好设置里改了jre的路径
这里写图片描述
在ADT这里,尝试着这么改,好像没用。。。。

还是按照上面那一段英文的方法改…..
添加:

-vm/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands

我只是添加了路径,并没有指明这个路径下的java,即不是
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
没想到也可以….

重启Eclipse ADT,New Android Project,next,next….finish,OK!
这里写图片描述



mac开发确实很爽,可是总会遇到一些很蛋疼的问题。。。。。。
明天考完试,我就去下载Android Studio,实在是受够了ADT了。。。。。


百度搜出一堆废话,唯独看到两个对我有很大帮助的博客,附上链接:
Link 1
Link 2
然……我也想说:此时两个字形容心情:(ni)呵(ma)呵(B)

0 0
原创粉丝点击