Android Emulator 不会运行从 Eclipse 启动的应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2793956/
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
Android Emulator won't run application started from eclipse
提问by Christian Tang
I have followed the "Hello World" example from Google's Android developer's guide. When I try to run the application in the SDK emulator, nothing happens. The emulator startd up nicely, but after that nothing happens. I can't even see the application in the app tray.
我遵循了 Google 的 Android 开发人员指南中的“Hello World”示例。当我尝试在 SDK 模拟器中运行应用程序时,没有任何反应。模拟器启动得很好,但之后什么也没有发生。我什至看不到应用程序托盘中的应用程序。
I am using Eclipse with the Android add-on installed.
我正在使用安装了 Android 插件的 Eclipse。
采纳答案by baroquedub
Same here; emulator loads fine but apk doesn't get installed. Problem is only with the emulator. All works fine if physically connecting a device with USB debugging turned on.
同样在这里; 模拟器加载正常,但未安装 apk。问题仅与模拟器有关。如果在打开 USB 调试的情况下物理连接设备,则一切正常。
NB This suddenly started happening for no apparent reason. All used to work fine.
注意这突然开始发生,没有明显的原因。一切都用来工作正常。
I've tried uninstalling and reinstalling the ADT Plugin and I've updated the Android SDK and AVD Manager to the latest available. (Tools revision 7) but the problem continues.
我已尝试卸载并重新安装 ADT 插件,并且已将 Android SDK 和 AVD 管理器更新为可用的最新版本。(工具修订版 7)但问题仍然存在。
Eclipse: Helios Service Release 1 Build id: 20100917-0705 Running on Windows XP SP2
Eclipse:Helios Service Release 1 Build id:20100917-0705 在 Windows XP SP2 上运行
Just as others have posted, the console log shows
正如其他人发布的那样,控制台日志显示
[2010-10-14 11:39:33 - uad-MediaPlayerExample] ------------------------------
[2010-10-14 11:39:33 - uad-MediaPlayerExample] Android Launch!
[2010-10-14 11:39:33 - uad-MediaPlayerExample] adb is running normally.
[2010-10-14 11:39:33 - uad-MediaPlayerExample] Performing com.msi.manning.chapter10.MediaPlayerExample.MediaPlayerActvity activity launch
[2010-10-14 11:39:33 - uad-MediaPlayerExample] Automatic Target Mode: launching new emulator with compatible AVD '1.6-hvga'
[2010-10-14 11:39:33 - uad-MediaPlayerExample] Launching a new emulator with Virtual Device '1.6-hvga'
LogCat remains empty/blank.
LogCat 保持为空/空白。
And if I then try to re-run the same app, the console shows:
如果我然后尝试重新运行同一个应用程序,控制台会显示:
[2010-10-14 11:39:33 - Emulator] emulator: ERROR: the user data image is used by another emulator. aborting
POSSIBLE ANSWER???
One solution seems to be to kill the adb.exe process in Windows Task Manager (while the emulator is still running).
可能的答案???一种解决方案似乎是在 Windows 任务管理器中终止 adb.exe 进程(当模拟器仍在运行时)。
The console suddenly shows lots of errors:
控制台突然显示很多错误:
[2010-10-14 12:12:00 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:01 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:01 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:02 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:02 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:03 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:03 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:04 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:04 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:05 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:05 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
[2010-10-14 12:12:06 - DeviceMonitor]Sending Tracking request failed!
[2010-10-14 12:12:06 - DeviceMonitor]Adb connection Error:An existing connection was forcibly closed by the remote host
but the app starts in the emulator. !!!
但应用程序在模拟器中启动。!!!
(as expected the LogCat also suddenly starts to display lots of messages)
(正如预期的那样,LogCat 也突然开始显示大量消息)
All works fine - i.e. you can work on your code and re-run the app in the same emulator and it reinstalls as expected...
一切正常 - 即您可以处理您的代码并在同一个模拟器中重新运行该应用程序并按预期重新安装...
BUTif you close the emulator, you see the following console error:
但是,如果关闭模拟器,则会看到以下控制台错误:
[2010-10-14 12:15:05 - DeviceMonitor]Sending jdwp tracking request failed!
And the same problem reoccurs - a new emulator appears but the apk isn't installed. So you need to go back to Windows Task Manager and once again kill the adb.exe process.
同样的问题再次出现 - 出现了一个新的模拟器,但未安装 apk。因此,您需要返回 Windows 任务管理器并再次终止 adb.exe 进程。
NB I find that adb.exe doesn't reappear in the Task Manager unless I restart Eclipse, so after closing an emulator you have to restart Eclipse, try Run (which fails to display the app) then go back to the Task Manager where adb.exe is once again listed and kill the process for the app to start.
注意,除非我重新启动 Eclipse,否则我发现 adb.exe 不会重新出现在任务管理器中,因此在关闭模拟器后,您必须重新启动 Eclipse,尝试运行(无法显示应用程序),然后返回到任务管理器中的 adb .exe 再次列出并终止应用程序启动的进程。
Would be great if someone could provide an explanation for this and a permanent fix...
如果有人可以为此提供解释和永久修复,那就太好了...
回答by Sven Boehringer
Had the same problem, the console log stalled after:
有同样的问题,控制台日志在以下之后停止:
Launching a new emulator with Virtual Device
使用虚拟设备启动新模拟器
and the emulator never showed the HelloAndroid application. I finally figured it out! In Eclipse go to
并且模拟器从未显示 HelloAndroid 应用程序。我终于想通了!在 Eclipse 中转到
Run --> Run Configurations
运行 --> 运行配置
Then change the Launch Action for your application (e.g. HelloAndroid) from "Launch Default Activity" to "Launch:" and then select your application from the pull-down menu. This did the trick for me.
然后将您的应用程序(例如 HelloAndroid)的启动操作从“启动默认活动”更改为“启动:”,然后从下拉菜单中选择您的应用程序。这对我有用。
HTH, Sven
HTH,斯文
回答by the mighty fd
I have the similar problem. I suggest the following workaround:
我有类似的问题。我建议以下解决方法:
- close eclipse, in the Task Manager, kill all adb and emulator* processes.
- start eclipse, run your application, wait untill the emulator starts. If you have the problem, your application won't be started, there will be the bare emulator.
- In eclipse, select Window->Open Perspective->Other->DDMS. Switch to DDMS perspective. If you have the problem, the list of the devices will be empty.
- In the Devices tab, in the drop-down box, select "reset adb". In a short while, the emulator must appear in the devices list.
- Following that, switch back to your Java perspective and run your app. Everything must work fine for the rest of the session.
- 关闭 eclipse,在任务管理器中,杀死所有 adb 和 emulator* 进程。
- 启动eclipse,运行你的应用程序,等到模拟器启动。如果您遇到问题,您的应用程序将无法启动,只会出现裸模拟器。
- 在eclipse中,选择Window->Open Perspective->Other->DDMS。切换到 DDMS 视角。如果出现问题,设备列表将为空。
- 在设备选项卡的下拉框中,选择“重置 adb”。很快,模拟器必须出现在设备列表中。
- 之后,切换回您的 Java 透视图并运行您的应用程序。在接下来的会话中,一切都必须正常工作。
回答by Oscar
Actually, if you are using Windows, the problem might be that the User Account Control in your Windows is preventing Eclipse to load the apk in the emulator (Eclipse doesn't have right to do so).
实际上,如果您使用的是 Windows,问题可能在于 Windows 中的用户帐户控制阻止 Eclipse 在模拟器中加载 apk(Eclipse 无权这样做)。
To turn off the User Account Control, go to the Control Panel, click User Accounts and Family Safety, and then click User Accounts. Once there, click the option 'Turn User Account Control on or off'.
要关闭用户帐户控制,请转到控制面板,单击用户帐户和家庭安全,然后单击用户帐户。在那里,单击“打开或关闭用户帐户控制”选项。
回答by Hyman
Same problem. Killing adb from task manager didn't help. Also tried restarting the AVD using android create avd --target 2 --name my_avd --force, no good. Tried the different launch method in Eclipse, nada.
同样的问题。从任务管理器中杀死 adb 没有帮助。还尝试使用 android create avd --target 2 --name my_avd --force 重新启动 AVD,不好。在 Eclipse 中尝试了不同的启动方法,nada。
What eventually helped is: I started (from the start menu, not command line) the Android SDK Tools > SDK Manager, found the my_avd under virtual devices, and simply clicked the Start... button. That did it - the emulator started, I ran from Eclipse, and it immediately showed the app on the emulator.
最终有帮助的是:我启动(从开始菜单,而不是命令行)Android SDK 工具 > SDK 管理器,在虚拟设备下找到 my_avd,然后只需单击开始...按钮。这样做了 - 模拟器启动,我从 Eclipse 运行,它立即在模拟器上显示应用程序。
回答by milous
One solution is go to android sdk/tools directory and start ddms.bat for Dalvik Debug Monitor, then select Actions->Reset adb. That seem to fix the problem
一种解决方案是转到 android sdk/tools 目录并为 Dalvik Debug Monitor 启动 ddms.bat,然后选择 Actions->Reset adb。这似乎解决了问题
回答by milous
Depending on your computer it can takes several minutes to load the emulator and the app. Open Logcat view to see the progress of loading.
根据您的计算机,加载模拟器和应用程序可能需要几分钟时间。打开Logcat视图查看加载进度。
回答by Sorokin Andrey
In my case the problem occurs because of the simple thing: i do not select the project that i want to run. Click on it in solution folder, then press run and enjoy. Hope it will help someone.
在我的情况下,问题发生的原因很简单:我没有选择要运行的项目。在解决方案文件夹中单击它,然后按运行并享受。希望它会帮助某人。
回答by SRK
STEPS TO FOLLOW:
要遵循的步骤:
- Go to Command Prompt
- type adb kill-server
- enter
- 转到命令提示符
- 输入 adb kill-server
- 进入
Now it should work fine
现在它应该可以正常工作
回答by Vijay C
I used to face this problem a lot. There is workaround for this,
我曾经经常面对这个问题。有解决方法,
End the "adb.exe" process from the Task Manager and try again.
从任务管理器结束“adb.exe”进程,然后重试。
It should work. and instead of running from eclipse i use following batch files in my project directory to install and uninstall the apk. Those work great.
它应该工作。而不是从 Eclipse 运行,我使用项目目录中的以下批处理文件来安装和卸载 apk。那些工作得很好。
Install.bat
安装.bat
cd bin
adb install *.apk
Uninstall.bat
卸载.bat
adb uninstall this.is.package.name