Android 应用程序无法从 Eclipse 启动

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

Android application doesn't start from Eclipse

androideclipseandroid-emulator

提问by Michael Pankov

Before u start: I searched the google and stackoverflow, none of them gave clear answer.

在你开始之前:我搜索了 google 和 stackoverflow,他们都没有给出明确的答案。

Situation: I'm using Eclipse on Windows to develop Android application. So when I'm trying to run the app, the system outputs to console

情况:我在 Windows 上使用 Eclipse 来开发 Android 应用程序。因此,当我尝试运行该应用程序时,系统会输出到控制台

[2010-06-14 17:04:39 - HelloLinearLayout] ------------------------------
[2010-06-14 17:04:39 - HelloLinearLayout] Android Launch!
[2010-06-14 17:04:39 - HelloLinearLayout] adb is running normally.
[2010-06-14 17:04:39 - HelloLinearLayout] Performing com.example.HelloLinearLayout.HelloLinearLayout activity launch
[2010-06-14 17:04:39 - HelloLinearLayout] Automatic Target Mode: launching new emulator with compatible AVD 'Default_2.1'
[2010-06-14 17:04:39 - HelloLinearLayout] Launching a new emulator with Virtual Device 'Default_2.1'

starts the emulator, but doesn't upload the .apk and doesn't start the activity. So, app is not started anyway.

启动模拟器,但不上传 .apk 并且不启动活动。因此,无论如何都不会启动应用程序。

I found a "solution" here, but it's unclear and seems to not work. For example, I don't know, which "emulator processed" are meant to be killed. I found adb.exe only. And that's the main point: sometimes I'm lucky enough to kill all that they wanted and start the app. But it's undetermined.

我在这里找到了一个“解决方案” ,但不清楚,似乎不起作用。例如,我不知道,哪个“模拟器处理”是要被杀死的。我只找到了 adb.exe。这就是重点:有时我很幸运能够杀死他们想要的所有东西并启动应用程序。但它是不确定的。

Please help, I'm completely stuck with this trouble.

请帮忙,我完全被这个麻烦困住了。

采纳答案by skirmish

I've run into this situation many times and have had to do several things to resolve the issue.

我遇到过这种情况很多次,不得不做几件事来解决这个问题。

1) If DDMS is running, close it (it seems to interfere with debugging sometimes).

1)如果DDMS正在运行,关闭它(它似乎有时会干扰调试)。

2) Start the emulator, try connecting with DDMS, then disconnect, then go back to eclipse and start the debuggerer.

2)启动模拟器,尝试连接DDMS,然后断开连接,再回到eclipse启动调试器。

3) Kill the emulator, kill the adb process in task manager, restart eclipse, then try debugging letting Eclipse launch the emulator, sometimes the first load of the emulator times out so when it's fully started up, start debugging again.

3)杀死模拟器,杀死任务管理器中的adb进程,重新启动eclipse,然后尝试调试让Eclipse启动模拟器,有时模拟器的第一次加载超时,所以当它完全启动时,再次开始调试。

Overall though, I've found it is much easier to not use the emulator and use an actual device, for me it's a much faster process.

不过总的来说,我发现不使用模拟器而使用实际设备要容易得多,对我来说这是一个更快的过程。

回答by Nikhil Kashyap

I've tried a bunch of things for Eclipse on Windows and this set-up finally worked for me. Now I can repeatedly run the emulator and deploy the app successfully:

我已经在 Windows 上为 Eclipse 尝试了很多东西,这个设置最终对我有用。现在我可以重复运行模拟器并成功部署应用程序:

  • In Run Configurations ->Select the Deployment Target Selection Mode as "Manual"
  • Then Hit Run. The "Android Device Chooser" shows up
  • Select the "Launch a new Android Virtual Device" option (this should show the AVD that you had already pre-configured)
  • Select the AVD there and hit Start
  • Check only the "Wipe User Data" and un-check the other checkboxes
  • Hit Launch. This should launch the emulator. Give it sometime to run. Ensure that the home screen with the Android icon (and Google search bar) shows up. It's important to wait till this shows up. Otherwise, the app won't load. Depending on how fast your CPU is, the time taken for the home screen to load will vary.
  • Once the emulator home screen shows, go back to Eclipse, select this emulator in the Android Device Chooser (the state should be online)
  • Click OK once you have selected this emulator
  • The app will be loaded on to the emulator (give it sometime) and you should see your app running on the emulator
  • 在运行配置->选择部署目标选择模式为“手动”
  • 然后点击运行。“Android 设备选择器”出现
  • 选择“启动新的 Android 虚拟设备”选项(这应该显示您已经预先配置的 AVD)
  • 在那里选择 AVD 并点击开始
  • 仅选中“擦除用户数据”并取消选中其他复选框
  • 点击启动。这应该会启动模拟器。给它一些时间运行。确保显示带有 Android 图标(和 Google 搜索栏)的主屏幕。重要的是要等到这出现。否则,应用程序将无法加载。根据您的 CPU 速度,主屏幕加载所需的时间会有所不同。
  • 模拟器主屏幕显示后,返回 Eclipse,在 Android Device Chooser 中选择此模拟器(状态应为在线)
  • 选择此模拟器后单击“确定”
  • 该应用程序将被加载到模拟器上(有时间给它),您应该会看到您的应用程序在模拟器上运行

This setup seemed to work for me every time. I can't fully comprehend why this works, while the other "normal" way doesn't. But I'm glad, I could get the emulator and the app working finally.

这种设置似乎每次都对我有用。我无法完全理解为什么这有效,而另一种“正常”方式则不然。但我很高兴,我终于可以让模拟器和应用程序运行起来。

回答by Nobody

I was experiencing this issue in Linux (Mint 12, Eclipse Juno Java EE for Web Developers, Android API20, Sun Java 1.6). I could launch the emulator from the command line just fine (i.e., "emulator-arm -avd InsertYourVirtualDeviceNameHere -verbose"), but not from within Eclipse. It just hung like the original poster mentioned. The way I fixed it was to make a backup of the original "emulator" for safe keeping and then I made a copy of "emulator-arm" and renamed it "emulator". These emulators are located within the "tools" directory of your Android SDK installation. I'm still trying to figure out how to get Eclipse to correctly point to "emulator-arm" on its own without this hack.

我在 Linux(Mint 12、Eclipse Juno Java EE for Web Developers、Android API20、Sun Java 1.6)中遇到了这个问题。我可以很好地从命令行启动模拟器(即“emulator-arm -avd InsertYourVirtualDeviceNameHere -verbose”),但不能从 Eclipse 中启动。它就像上面提到的原始海报一样挂着。我修复它的方法是备份原始“模拟器”以确保安全,然后我制作了“emulator-arm”的副本并将其重命名为“emulator”。这些模拟器位于您的 Android SDK 安装的“工具”目录中。我仍在试图弄清楚如何让 Eclipse 在没有这个 hack 的情况下自己正确地指向“模拟器臂”。

回答by Yonatan Nir

It happened to me as well. It seemed that for me the issue was that the app was already running on the device I installed the apk to. When I closed it, it worked.

它也发生在我身上。对我来说,问题似乎是该应用程序已经在我安装了 apk 的设备上运行。当我关闭它时,它起作用了。

回答by mounika

If You Running In Eclipse, Check Your Settings.

如果您在 Eclipse 中运行,请检查您的设置。

Run Configurations - Common - Select File In Standard Input And Output - Click

运行配置——通用——在标准输入输出中选择文件——点击

Workspace And Choose Your Project.

工作区并选择您的项目。