Android 在 Eclipse 中解析 A​​ndroid sdk 内容和初始化 java 工具时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10140732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:38:51  来源:igfitidea点击:

Error with parsing Android sdk content and initializing java tooling in eclipse

androideclipsemacosnullpointerexception

提问by Njaal Gjerde

Every time I open Eclipse, I get the following error messages:

每次打开 Eclipse 时,都会收到以下错误消息:

Android SDK Content Loader: parseSdkContent failed java.lang.NullPointerException

Android SDK 内容加载器:parseSdkContent 失败 java.lang.NullPointerException

Initializing Java Tooling An internal error occured during: "Initializing Java Tooling". java.lang.NullPointerException

初始化 Java 工具 在“初始化 Java 工具”期间发生内部错误。java.lang.NullPointerException

Loading data for Android 2.2 Parsing Data for android-8 failed java.lang.NullPointerException

为 Android 2.2 加载数据为 android-8 解析数据失败 java.lang.NullPointerException

Loading data for Android 2.3.3 Parsing Data for android-10 failed java.lang.NullPointerException

为 Android 2.3.3 加载数据为 android-10 解析数据失败 java.lang.NullPointerException

Loading data for Google APIs (Google Inc.) Parsing Data for Google Inc.: Google APIs:8 failed java.lang.NullPointerException

为 Google API 加载数据 (Google Inc.) 为 Google Inc. 解析数据:Google APIs:8 failed java.lang.NullPointerException

See link for screenshot: http://i.stack.imgur.com/lhhQQ.png

截图见链接:http: //i.stack.imgur.com/lhhQQ.png

(I am using OS X Lion, and Eclipse Helios)

(我使用的是 OS X Lion 和 Eclipse Helios)

First i read some posts saying that it was the AVD.ini file in the .android profile that was causing the trouble. I tried deleting all the entire .android profile folder as suggested in Android SDK Content Loader failing with NullPointerException. This didn't correct my problem.

首先,我读了一些帖子,说是 .android 配置文件中的 AVD.ini 文件导致了问题。我尝试按照Android SDK Content Loader failed with NullPointerException 中的建议删除所有整个 .android 配置文件文件夹。这并没有纠正我的问题。

I tried deleting the entire Android SDK folder, downloaded it again and installed a couple of Android versions through it. Still the same error messages...

我尝试删除整个 Android SDK 文件夹,再次下载并通过它安装了几个 Android 版本。还是一样的错误提示...

To ensure that I didn't have any old plugins or something that were the issue, I uninstalled eclipse, downloaded it again and installed the Android plugin again. (So the plugin is up to date).

为了确保我没有任何旧插件或其他问题,我卸载了 eclipse,再次下载并再次安装了 Android 插件。(所以插件是最新的)。

When I go into one of my Android projects, I get error messages on places where I acces resources by using the R file. Regular Java projects work fine, but all Android projects gets small red boxes with white crosses on them. I have been searching for a solution to this problem since yesterday, but at this point I'm completely qlueless and would appreciate any help I can get!

当我进入我的一个 Android 项目时,我在使用 R 文件访问资源的地方收到错误消息。常规 Java 项目工作正常,但所有 Android 项目都会得到带有白色十字的小红框。从昨天开始,我一直在寻找解决这个问题的方法,但在这一点上,我完全没有问题,希望得到任何帮助!

回答by slott

Close all open projects and exit Eclipse. Now you can open Eclipse without getting the error. Start opening your projects one by one to find which one causes the problem. This is most likely because you deleted a Device profile inside the AVD manager.

关闭所有打开的项目并退出 Eclipse。现在您可以打开 Eclipse 而不会出现错误。开始一一打开您的项目,找出导致问题的原因。这很可能是因为您删除了 AVD 管理器中的设备配置文件。

回答by Raymond Chenon

I encountered exactly the same issue this morning. This is a workspace related issue.

我今天早上遇到了完全相同的问题。这是一个与工作区相关的问题。

Solution 1
I looked into my .metadata and read .bak_number.log files . Some layouts failed to parse and my projects were out of sync with the file system. So I deleted all the .bak_number.log files. Relaunch Eclipse and the whole worskspace should work again the way you left previously.

解决方案 1
我查看了我的 .metadata 并阅读了 .bak_ number.log 文件。一些布局无法解析,我的项目与文件系统不同步。所以我删除了所有的 .bak_number.log 文件。重新启动 Eclipse,整个工作区应该会按照您之前离开的方式再次运行。

Solution 2
However if it's not due to out of sync with the file system. Change the workspace then import all the eclipse projects from the previous workspace. Thanks the project.properties files , the dependencies are still kept.

解决方案 2
但是,如果不是由于与文件系统不同步。更改工作区,然后从以前的工作区导入所有 eclipse 项目。感谢 project.properties 文件,依赖项仍然保留。

PS : I should return to IntelliJ :)

PS:我应该回到 IntelliJ :)

回答by raj

Do not delete all the full .metadata

不要删除所有完整的 .metadata

  • Backup .metadata
  • delete only .metadata/.plugins/org.eclipse.core.resources/.project
  • restart eclipse
  • 备份 .metadata
  • 仅删除 .metadata/.plugins/org.eclipse.core.resources/.project
  • 重启日食

Observation : the projects folders are created

观察:创建了项目文件夹

Further - if you are using svn/git/hg have code repository links it would be destroyed, so to reinstate

此外 - 如果您使用 svn/git/hg 有代码存储库链接,它将被销毁,因此要恢复

  • close eclipse
  • copy relevant projects from backup to merge with current projects in .metadata/.plugins/org.eclipse.core.resources/.project
  • restart eclipse
  • 日食
  • 从备份中复制相关项目以与 .metadata/.plugins/org.eclipse.core.resources/.project 中的当前项目合并
  • 重启日食

Downfall - sporadic fail error may occur (sync or something) - harmless

垮台 - 可能会发生零星的失败错误(同步或其他) - 无害

backagain

再次回来

回答by Tushar Dharashivkar

  1. first close your Eclipse

  2. Go to your workspace and rename .metadata to tushmetadata and go to tushmetadata- >.plugins -> org.eclipse.core.runtime -> .settings and copy all files from it.

  3. now open the Eclipse and go to your workspace there you can see the newly generated .metadata folder in that go to .plugins -> org.eclipse.core.runtime -> .settings and paste here and do not overwrite any file.

  4. Try to "Hello World" project and run it.

  1. 首先关闭你的 Eclipse

  2. 转到您的工作区并将 .metadata 重命名为 tushmetadata 并转到 tushmetadata->.plugins -> org.eclipse.core.runtime -> .settings 并从中复制所有文件。

  3. 现在打开 Eclipse 并转到您的工作区,在那里您可以看到新生成的 .metadata 文件夹,其中转到 .plugins -> org.eclipse.core.runtime -> .settings 并粘贴到此处,不要覆盖任何文件。

  4. 尝试“Hello World”项目并运行它。

回答by overbet13

When I met this problem about a year ago, I had some projects in my workspace that needed a specific Android SDK level (let's say 2.1) and i didn't have it installed in the Android SDK.

大约一年前我遇到这个问题时,我的工作区中有一些项目需要特定的 Android SDK 级别(假设为 2.1),但我没有在 Android SDK 中安装它。

回答by Jeff Axelrod

For me, the source of the NullPointerExceptionproblem was a host-side Junit test project that references (and tests) code from an Android project. It didn't have a project.propertiesfile. It's not an Android project, but for some reason the newer versions of the SDK somehow expects the file there. To fix the problem, I just copied a project.propertiesfile from an Android project to the host unit test project.

对我来说,NullPointerException问题的根源是一个主机端 Junit 测试项目,它引用(和测试)来自 Android 项目的代码。它没有project.properties文件。它不是 Android 项目,但出于某种原因,较新版本的 SDK 以某种方式期望该文件存在。为了解决这个问题,我只是将一个project.properties文件从 Android 项目复制到主机单元测试项目。

回答by ashutosh

Try to delete file .metadata from your android workspace folder. .Metadata folder contains all configuration files for eclipse. It works for me.

尝试从您的 android 工作区文件夹中删除文件 .metadata。.Metadata 文件夹包含 eclipse 的所有配置文件。这个对我有用。

回答by Njaal Gjerde

Your answers might be right. What I did was to change my workspace. I redownloaded the project I was going to work on from git, and reimported it. Now it works fine :) Maybe there was some files in this project that made the error messages apear? Dunno....

你的答案可能是对的。我所做的是改变我的工作空间。我从 git 重新下载了我要处理的项目,然后重新导入它。现在它工作正常:) 也许这个项目中有一些文件导致错误消息出现?不知道....

回答by jiahao

I have remove the .metadata folder but after it, when I run the eclipse, I cannot creates any Android project. To solve it, I have done the follow:

我已经删除了 .metadata 文件夹,但是在它之后,当我运行 eclipse 时,我无法创建任何 Android 项目。为了解决它,我做了以下工作:

  1. Go to the main work directory of eclipse
  2. Localize the folder com.android.ide.eclipse.adt It should be in .oldMetadata/.plugins/
  3. Copy it to the new eclipse configuration: .metadata/plugins/
  1. 进入eclipse的主工作目录
  2. 本地化文件夹 com.android.ide.eclipse.adt 应该在 .oldMetadata/.plugins/
  3. 将其复制到新的 eclipse 配置中:.metadata/plugins/

See the full solution here: http://www.jiahaoliuliu.com/2011/06/running-android-sdk-in-eclipse-errors.html#solution4

在此处查看完整解决方案:http: //www.jiahaoliuliu.com/2011/06/running-android-sdk-in-eclipse-errors.html#solution4

回答by araut

I hope this is useful to someone and saves his/her time: My colleague was facing same issue and we did almost everything mentioned here, with no luck. In the end we changed the Android SDK version in the manifest file and it worked.

我希望这对某人有用并节省他/她的时间:我的同事面临同样的问题,我们几乎做了这里提到的所有事情,但没有运气。最后,我们在清单文件中更改了 Android SDK 版本并且它起作用了。