Android 在“启动项目”期间发生内部错误。java.lang.NullPointerException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25847674/
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 09:45:14  来源:igfitidea点击:

An internal error occurred during: "Launching Project". java.lang.NullPointerException

androideclipsenullpointerexceptionadt

提问by Crawler

My android project was compiling well but suddenly it stopped launching. Then I tried to launch other projects from Project Explorer and all project threw same exception:

我的 android 项目编译良好,但突然停止启动。然后我尝试从 Project Explorer 启动其他项目,所有项目都抛出了相同的异常:

An internal error occurred during: "Launching Project". java.lang.NullPointerException

But console always shows everything is normal.

但是控制台总是显示一切正常。

Android Launch!
adb is running normally.
Performing com.mmcolrev.LoginActivity activity launch

Here's screenshot of error.

这是错误的屏幕截图。

enter image description here

在此处输入图片说明

回答by Crawler

If anyone face this problem, first keep in mind that error is not in your code but due to some internal issue in eclipse ADT. I don't know exact problem but luckily found way to solve it. If you ever encounter this error follow steps below:

如果有人遇到这个问题,首先要记住错误不在你的代码中,而是由于 Eclipse ADT 中的一些内部问题。我不知道确切的问题,但幸运的是找到了解决它的方法。如果您遇到此错误,请按照以下步骤操作:

  1. Exit Eclipse.
  2. Go to Android workspace.
  3. Locate .metadata folder(make sure you set hidden folder visibility on).
  4. Delete .metedata folder.
  5. Start Eclipse(you will notice project explorer is empty, don't panic) and import all your projects.
  1. 退出日食。
  2. 转到 Android 工作区。
  3. 找到 .metadata 文件夹(确保设置隐藏文件夹可见性)。
  4. 删除 .metadata 文件夹。
  5. 启动 Eclipse(您会注意到项目资源管理器是空的,不要惊慌)并导入您的所有项目。

回答by Orhan

I had the same issue.

我遇到过同样的问题。

Non of my project in the workspace would run and I would get the same message "An internal error occurred..." and details would just say something about a Nullpointer. This happend after I did some updates and all projects in the workspace started giving the same issue.

我的工作区中的任何项目都不会运行,并且我会收到相同的消息“发生内部错误...”,并且详细信息只会说明有关空指针的内容。这是在我进行了一些更新并且工作区中的所有项目都开始出现相同问题之后发生的。

It took me some time to find the problem:

我花了一些时间才找到问题:

When I go to configuration of the project (Run Configuration...) I could see that "Project" in the configuration settings was empty. So my update removed the projects from the configurations. Once I put back the project in the configuration again problem was gone.

当我转到项目配置(运行配置...)时,我可以看到配置设置中的“项目”为空。所以我的更新从配置中删除了项目。一旦我再次将项目放回配置中,问题就消失了。

回答by Ujjal Suttra Dhar

Removing Gen/R.java and restarting eclipse, worked for me.

删除 Gen/R.java 并重新启动 eclipse,对我有用。

回答by Muhammad Soliman

This is a cause of AVD is not picked because you might delete it or it is not picked up correctly ... in other words deployment target is not specified or it has some problem in picking up a device.

这是未选择 AVD 的原因,因为您可能将其删除或未正确选择……换句话说,未指定部署目标或在选择设备时出现问题。

To Resolve this:

要解决此问题:

  • Right click your project and choose "Properties"
  • From "Run/Debug" Settings, Highlight over your application name then hit "Edit..."
  • In "Target" tab, you have to choose a virtual device to be picked automatically under option named "Automatically pick compatible device..."
    • to avoid such prompt you could choose the first option "Always prompt to pick device" that will ask you everytime to choose or pick a device inside which you want to run your app.
  • 右键单击您的项目并选择“属性”
  • 从“运行/调试”设置中,突出显示您的应用程序名称,然后点击“编辑...”
  • 在“目标”选项卡中,您必须在名为“自动选择兼容设备...”的选项下选择要自动选择的虚拟设备。
    • 为避免此类提示,您可以选择第一个选项“始终提示选择设备”,该选项每次都会要求您选择或选择要在其中运行应用程序的设备。

If it still not working restart Eclipse

如果它仍然无法正常工作,请重新启动 Eclipse

回答by Jay Snayder

One cause of this issue for me was that I had been updating my Android Tools with the installer. It was running in the background doing all its updates. I had forgotten about it since I had told it to do the work in the background. Then realized it had finished its work and needed a restart after the installation.

对我来说这个问题的一个原因是我一直在使用安装程序更新我的 Android 工具。它在后台运行,执行所有更新。我已经忘记了,因为我告诉它在后台进行工作。然后意识到它已经完成了它的工作,需要在安装后重新启动。

Once the upgrade / installation was done and the IDE was restarted, the Eclipse environment went back to behaving as normal.

升级/安装完成并重新启动 IDE 后,Eclipse 环境恢复正常运行。

回答by sashoalm

In my case, it was because I was running it with Debug As -> Android Native Application, while the emulator was closed (I debugging on the emulator, not on a real phone).

就我而言,这是因为我使用 运行它Debug As -> Android Native Application,而模拟器已关闭(我在模拟器上调试,而不是在真正的手机上)。

I needed to first start the emulator using Debug As -> Android Application, after which Debug As -> Android Native Applicationwill work.

我需要先使用 启动模拟器Debug As -> Android Application,然后Debug As -> Android Native Application才能工作。

Close the emulator and the error re-appears. My conclusion is that Debug As -> Android Native Applicationwon't work unless the emulator is already started.

关闭模拟器,错误再次出现。我的结论是,Debug As -> Android Native Application除非模拟器已经启动,否则它不会工作。

回答by robert liebo

I had this error with an NDK project (eclipse mars, loaded an ant project) everytime i tried to lauch on the device (google tango yellowstone) using Debug As -> Android Native Application. Note, that i switched the device and changed a dependent library since the last successful build.

每次我尝试使用Debug As -> Android Native Application. 请注意,自上次成功构建以来,我切换了设备并更改了依赖库。

When i tried Debug As -> Android Applicationi got this message:

当我尝试时,Debug As -> Android Application我收到了这条消息:

Re-installation failed due to different application signatures. You must perform a full uninstall of the application. WARNING: This will remove the application data!

Do you want to uninstall?

由于不同的应用程序签名,重新安装失败。您必须完全卸载应用程序。警告:这将删除应用程序数据!

您要卸载吗?

clicking OK here solved the issue, so Debug As -> Android Native Applicationalso worked again.

在此处单击“确定”解决了该问题,因此Debug As -> Android Native Application也再次工作。

回答by puzzywuzzy

I had the same issue all of a sudden. This only happened when I ran in Debug mode, and for me what fixed it was... Run -> Remove All Breakpoints. Then I could add them back, and it ran in debug mode fine.

我突然遇到了同样的问题。这只发生在我在调试模式下运行时,对我来说修复的是......运行 - >删除所有断点。然后我可以将它们添加回来,它在调试模式下运行良好。

回答by jatin Goyal

To resolve this issue, I just remove the old JRE System Library and point to the new JRE System Library.

为了解决这个问题,我只是删除了旧的 JRE 系统库并指向新的 JRE 系统库。