简体   繁体   English

在Eclipse中运行Android应用程序会导致NullPointerException

[英]Running an Android App in Eclipse Causes NullPointerException

I have been following the Android getting started docs and when I try to run the project I get: 我一直在关注Android 入门文档 ,当我尝试运行该项目时,我得到了:

!MESSAGE An internal error occurred during: "Launching HelloAndroid".
!STACK 0
java.lang.NullPointerException
        at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.launch(Unknown Source)

The application doesn't launch. 该应用程序无法启动。

On Top Menu go to "Run" then "Run Configurations" and select your target virtual device. 在顶部菜单上,依次单击“运行”和“运行配置”,然后选择目标虚拟设备。 Click apply, and then run the project. 单击“应用”,然后运行项目。

Unplugging my Nexus One and restarting Eclipse fixed the problem. 拔下Nexus One并重新启动Eclipse即可解决此问题。 Not sure why. 不知道为什么。

  1. Launch ADV Manager, verify if there is an AVD for your Android Project target else create an ADV for your Target (Click on New... button, enter a Name, select your Target then press Create ADV button) 启动ADV管理器,验证您的Android Project目标是否有AVD,否则为目标创建ADV(单击New ...按钮,输入名称,选择目标,然后按Create ADV按钮)
  2. Run Eclipse, right-click on your Android Project name in the Package Explorer window 运行Eclipse,在Package Explorer窗口中右键单击您的Android项目名称
  3. Select Properties or press Alt+Enter 选择属性或按Alt + Enter
  4. Click on Run/Debug Settings then select your project name and click Edit 单击“运行/调试设置”,然后选择项目名称,然后单击“编辑”。
  5. Select Target tab 选择目标选项卡
  6. Click on Automatic and press Refresh button (If you have more AVD for the same Target: Select the checkbox the ADV verified or created at point 1) then click on Manual value) 单击“自动”,然后按“刷新”按钮(如果同一目标具有更多AVD:选中在点1处已验证或创建的ADV复选框),然后单击“手动值”)
  7. Press Apply button then OK button 按“应用”按钮,然后按“确定”按钮

Now you can run or debug your Android Project. 现在,您可以运行或调试Android项目。

Most likely you need to delete the existing launcher and recreate it as described in the other answers. 您很有可能需要删除现有的启动器,然后按照其他答案中的说明重新创建它。 You probably did some kind of refactoring or editing of the manifest file and the run configuration for some reason was not automatically updated. 您可能对清单文件进行了某种重构或编辑,由于某种原因,运行配置没有自动更新。 Maybe because your Eclipse plugin or SDK are outdated. 可能是因为您的Eclipse插件或SDK已过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM