Android 模拟器在启动时挂起?

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

Android emulator hanging on startup?

androidtestingandroid-emulator

提问by Chrisc

I've been modifying/editing parts of the Android platform, but have run into a problem when trying to test my edits. After making my changes to the platform source, I was able to successfully compile the source - thus creating system.img, ramdisk.img, and userdata.img.

我一直在修改/编辑 Android 平台的部分内容,但在尝试测试我的编辑时遇到了问题。在对平台源进行更改后,我能够成功编译源 - 从而创建 system.img、ramdisk.img 和 userdata.img。

When I go to test this in the emulator, the emulator just hangs on the "ANDROID_" screen, with the underscore blinking, but never seems to load. Any suggestions?

当我在模拟器中进行测试时,模拟器只是挂在“ANDROID_”屏幕上,下划线闪烁,但似乎从未加载过。有什么建议?

The command I used to run the emulator is as follows:

我用来运行模拟器的命令如下:

./emulator -system $HOME/android/platform/out/target/product/generic/system.img -ramdisk $HOME/android/platform/out/target/product/generic/ramdisk.img -data $HOME/android/platform/out/target/product/generic/userdata.img

./emulator -system $HOME/android/platform/out/target/product/generic/system.img -ramdisk $HOME/android/platform/out/target/product/generic/ramdisk.img -data $HOME/android/platform/out/target/product/generic/userdata.img

Thanks,
Chris

谢谢,
克里斯

采纳答案by BMB

The first startup can take a while, especially on a slow machine but otherwise try running the adb logcat command to see the log output. That will help you determine what the problem could be.

第一次启动可能需要一段时间,尤其是在速度较慢的机器上,否则请尝试运行 adb logcat 命令以查看日志输出。这将帮助您确定可能是什么问题。

Also if you like to skip supplying all the options to the emulator, i.e. -system and the other you can use the scripts supplied in the build folder. Run these commands from the open source project root folder:

此外,如果您想跳过向模拟器提供所有选项,即 -system 和其他选项,您可以使用构建文件夹中提供的脚本。从开源项目根文件夹运行这些命令:

source build/envsetup.sh
setpaths

The first one will run the envsetup script for Android that supplies a number of helpful commands. The second one sets up all the paths needed for Android platform development. Among them are the ANDROID_PRODUCT_OUT variable that informs the emulator where to look for the build images. It is set to the default folders that you have specified above. After running setpaths you can just start the emulator with your build by typing emulator on the command line.

第一个将运行 Android 的 envsetup 脚本,该脚本提供许多有用的命令。第二个设置了 Android 平台开发所需的所有路径。其中包括 ANDROID_PRODUCT_OUT 变量,它通知模拟器在哪里寻找构建图像。它设置为您在上面指定的默认文件夹。运行 setpaths 后,您可以通过在命令行上键入 emulator 来启动模拟器。

回答by Jay

I had this problem and fixed it by deleting the emulator and creating a new one. In eclipse:

我遇到了这个问题并通过删除模拟器并创建一个新的模拟器来修复它。在日食中:

  1. Menu Window -> Android SVK and AVD Manager
  2. Select Virtual devices (should be selected already)
  3. Select the emulator giving you problems
  4. Edit to see the setting and remember them.
  5. Delete the emulator.
  6. Create a new one that is the same as the old one.
  7. Start the emulator from here with the start button.
  1. 菜单窗口 -> Android SVK 和 AVD 管理器
  2. 选择虚拟设备(应该已经选择了)
  3. 选择给你问题的模拟器
  4. 编辑以查看设置并记住它们。
  5. 删除模拟器。
  6. 创建一个与旧的相同的新的。
  7. 使用启动按钮从这里启动模拟器。

It started in about 30 seconds after I did that.

它在我这样做后大约 30 秒内开始。

Normally the emulator starts in about 2-3 minutes for me. Then it mysteriously stopped working. I was seeing boot animation for 30 minutes before I gave up. Rebooting my laptop didn't help, which made me think it was a problem with the emulator settings, and I stumbled on this solution.

通常模拟器会在大约 2-3 分钟内启动。然后它神秘地停止工作。在我放弃之前,我看了 30 分钟的开机动画。重新启动我的笔记本电脑没有帮助,这让我认为这是模拟器设置的问题,我偶然发现了这个解决方案。

  • Note #1: Doing this will wipe your user data.
  • Note #2: As mentioned else where, it's a good idea to check "Enabled" for the Snapshot when you create or edit the emulator, this lets you do faster startup next time.
  • Note #3: My new emulator came up in chinese. That's kinda of weird :)
  • 注意#1:这样做会擦除您的用户数据。
  • 注意#2:正如其他地方提到的,在创建或编辑模拟器时为快照选中“已启用”是个好主意,这可以让您下次启动更快。
  • 注意#3:我的新模拟器是中文的。这有点奇怪:)

回答by mujtaba

Try using adb logcatin the terminal to see what's happening with the emulator. When I did that I kept noticing

尝试adb logcat在终端中使用以查看模拟器发生了什么。当我这样做时,我一直注意到

I/ServiceManager(  918): service 'media.audio_flinger' died
I/ServiceManager(  918): service 'media.player' died
I/ServiceManager(  918): service 'media.camera' died
I/ServiceManager(  918): service 'media.audio_policy' died

repeating every 10s or so. I tried enabling my cameras in the AVD and the emulator started working.

每 10 秒左右重复一次。我尝试在 AVD 中启用我的相机,模拟器开始工作。

To enable the camera enter android avdin the terminal and set the front and back camera options.

要启用摄像头android avd,请在终端中输入并设置前后摄像头选项。

回答by Jorge M. Londo?o P.

I had a similar problem. The emulator was unresponsive and Android Studio was unable to deploy and run the application. My solution was the following: 1. Open the AVD manager 2. On right hand side menu of the virtual device issue the commands "Stop" and "Wipe data" 3. Then, do a cold boot of the virtual device and voila, it came back to life.

我有一个类似的问题。模拟器没有响应,Android Studio 无法部署和运行应用程序。我的解决方案如下: 1. 打开 AVD 管理器 2. 在虚拟设备的右侧菜单上发出“停止”和“擦除数据”命令 3. 然后,对虚拟设备进行冷启动,瞧,它活了过来。

回答by John

I normally have to restart it to get it to run. Today it wouldn't restart no matter what. Doing a ./adb logcat consistently showed 'waiting for device'. So I restarted it using Eclipse Android SDK and AVD Manager / Start... (option), un-checking the 'Launch from snapshot' option, and after the long grind of load it, the emulator works.

我通常必须重新启动它才能运行。今天无论如何都不会重启。执行 ./adb logcat 始终显示“等待设备”。因此,我使用 Eclipse Android SDK 和 AVD Manager / Start...(选项)重新启动它,取消选中“从快照启动”选项,经过长时间的加载,模拟器工作。

回答by user1364368

My trick to get the emulator started on a weak machine (RAM: just 1 GB) is to start it as first thing after WinXP has finished booting. Further, using an emulator instance with a smaller resolution (smaller number of pixels on display to emulate, e.g. just 240x400) did also help.

我在弱机器(RAM:只有 1 GB)上启动模拟器的技巧是在 WinXP 完成启动后首先启动它。此外,使用分辨率较小的模拟器实例(显示器上要模拟的像素数量较少,例如仅 240x400)也有帮助。