Android 使用 VMWare/VirtualBox 等虚拟机进行调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10648009/
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
Debugging using a virtual machine like VMWare/VirtualBox?
提问by Trikaldarshi
I am developing an Android application but fed-up of performance of My emulator
I do have a Android PC version
installed in both VM-ware and Virtual Box
我正在开发一个 Android 应用程序,但厌倦了My emulator
我Android PC version
在 VM-ware 和Virtual Box
Can I use it as emulator? If so, how? How can I connect ADBto a virtual machine running PC Android?
我可以将其用作模拟器吗?如果是这样,如何?如何将ADB连接到运行 PC Android 的虚拟机?
I saw in some forum to use this but my VMsandroid having no specific IP.
我在一些论坛上看到使用这个,但我的虚拟机android 没有特定的 IP。
How to i connect it??
我怎么连接它??
采纳答案by Trikaldarshi
Solution:
解决方案:
I would highly recommend to use Android x86 coz it many many times faster than Android emulator with Android x86 4.2 you can install and use any application with this and use "Google play" synch with your account as you do it with tablet
我强烈建议使用 Android x86 因为它比带有 Android x86 4.2 的 Android 模拟器快很多倍,您可以安装和使用任何应用程序,并使用“Google play”与您的帐户同步,就像使用平板电脑一样
Working with latest Android X86 4.2 Jelly Bean and Virtual Box
使用最新的 Android X86 4.2 Jelly Bean 和 Virtual Box
I have found Different ways to connect with Internet and adb
我找到了连接 Internet 和 adb 的不同方法
Step: 1 Selection of Adapters
步骤:1 适配器的选择
CASE 1: Only Internet {NAT Adapter}
案例 1:只有 Internet {NAT Adapter}
The easiest solution is just use NAT adapter that will directly connect you to internet if host is connected to internet but you won't get the adb connection with this setup Here you will get Public ip so you can't connect to Host computer
最简单的解决方案是使用 NAT 适配器,如果主机连接到互联网,它将直接将您连接到互联网,但您将无法通过此设置获得 adb 连接在这里您将获得公共 IP,因此您无法连接到主机
Case 2: Only adb {Host Only Adapter}
案例 2:只有 adb {Host Only Adapter}
The easiest solution is just use Host Only Adapter
最简单的解决方案是使用 Host Only Adapter
Note:The default Host Only adapter may not work due to DHCP server settings either create new HostOnlyAdapter
or run DHCP server
for existing Adapter()
注意:默认的 Host Only 适配器可能无法工作,因为 DHCP 服务器设置要么创建新的,HostOnlyAdapter
要么DHCP server
为现有的 Adapter()运行
Case 3: For both adb and Internet {Bridge Adapter}
案例 3:对于 adb 和 Internet {Bridge Adapter}
You will have to take care in this case.
在这种情况下,您必须小心。
If you are using LAN for internet connection you shall use Bridge Adapter with your Ethernet card it will give you local ip and Virtual Machine will connect to Internet using host machine
如果您使用 LAN 进行 Internet 连接,则应使用网桥适配器和以太网卡,它将为您提供本地 IP,虚拟机将使用主机连接到 Internet
Alternatively if you are with Wifi just do the same by selecting the Wifi adapter
或者,如果您使用 Wifi,只需选择 Wifi 适配器即可
For other type of connection you shall go with the same way
对于其他类型的连接,您将采用相同的方式
Step: 2 Connection with adb
步骤:2 与 adb 的连接
to check the ip Address just press Alt+F1{for console Window} [To switch back to Graphics view press Alt+F7]
要检查 IP 地址,只需按Alt+F1{for console Window} [要切换回图形视图,请按Alt+F7]
you will see the console window type netcfg
您将看到控制台窗口类型netcfg
it will show the ip address
它会显示IP地址
Now move on to you host run command prompt move to adb directory type
现在转到您的主机运行命令提示符移动到 adb 目录类型
adb connect {your ip address}
Example
例子
adb connect 192.168.1.51
亚行连接 192.168.1.51
Note: if adb is not running or responding you can do following
注意:如果 adb 未运行或未响应,您可以执行以下操作
adb kill-server
adb start-server
you can check devices connected to adb
您可以检查连接到 adb 的设备
adb devices
回答by Ben Max Rubinstein
As per your edited question, if you want to connect it to ADB you need to check what the IP of the VM is: Assuming you use VMWare's player;
根据您编辑的问题,如果要将其连接到 ADB,则需要检查 VM 的 IP 是什么:假设您使用 VMWare 的播放器;
Hit ALT-F1in the VM and use the ifconfig
command to know the IP address given to your network device (usually eth0
). You can then hit ALT-F7to go back to the Android UI.
ALT-F1在 VM 中点击并使用该ifconfig
命令了解提供给您的网络设备的 IP 地址(通常为eth0
)。然后您可以点击ALT-F7返回 Android UI。
Then, in your host PC, execute the adb connect [ANDROID_X86_IP]
to connect the SDK debugger to your Android x86 VM; for example: adb connect 192.168.1.100:5555
.
然后,在您的主机 PC 中,执行adb connect [ANDROID_X86_IP]
将 SDK 调试器连接到您的 Android x86 VM;例如:adb connect 192.168.1.100:5555
。
You should then see the list of devices connected and then it will be enabled to use for debugging.
然后您应该看到连接的设备列表,然后它将被启用以用于调试。
ADB is typically located on your computer in a subfolder to your user folder in: ~/Android/Sdk/platform-tools
. It is recommended to add it to your path so you can access it using the terminal wherever. I personally use this in ~/.bash_profile
:
ADB 通常位于您计算机上用户文件夹的子文件夹中:~/Android/Sdk/platform-tools
。建议将其添加到您的路径中,以便您可以在任何地方使用终端访问它。我个人在~/.bash_profile
以下方面使用它:
#add Android platform-tools directory
PATH=~/android-sdks/platform-tools:$PATH
export PATH
In case ADB fails the first time, you can try adb kill-server ; adb start-server
to reset ADB.
如果 ADB 第一次失败,您可以尝试adb kill-server ; adb start-server
重置 ADB。
If you want to read further, check out the Android-x86 website. It also has a lot of disc images available for download.
如果您想进一步阅读,请查看 Android-x86 网站。它还具有大量可供下载的光盘映像。
回答by pankaj sharma
install android x86 on vmware
run android terminal write command "ifconfig eth0"
windows user make Environment C:\Users\user- name\AppData\Local\Android\sdk\platform-tools
- "adb connect IP address of the VM":5555 now run app on vmware
在 vmware 上安装 android x86
运行android终端写入命令“ifconfig eth0”
windows user make Environment C:\Users\user-name\AppData\Local\Android\sdk\platform-tools
- “adb 连接虚拟机的 IP 地址”:5555 现在在 vmware 上运行应用程序
回答by Victor Ronin
This is not a direct answer to your question, but did you see tricks to increase performance of emulator (read Why is the Android emulator so slow? How can we speed up the Android emulator?)
这不是对您问题的直接回答,但您是否看到了提高模拟器性能的技巧(阅读为什么 Android 模拟器如此慢?我们如何加快 Android 模拟器的速度?)
a) Use Intel Atom x86 instead of ARM
a) 使用 Intel Atom x86 而不是 ARM
b) Use hw.gpu.enabled
b) 使用 hw.gpu.enabled
I would say this makes emulator quite comparable in performance to a real device.
我会说这使得模拟器在性能上与真实设备相当。
Update 1
更新 1
Generally speaking, the idea is to configure Android PC to use tcp/ip for adb connection. And you may need to play around with network settings on VMWare or VirtualBox.
一般来说,思路是配置安卓PC使用tcp/ip进行adb连接。您可能需要在 VMWare 或 VirtualBox 上使用网络设置。
Useful links (which try to accomplish what you want
有用的链接(尝试完成您想要的
No network connection - Android-x86 on VMWare Fusionhttp://lkubaski.wordpress.com/2012/08/15/running-android-on-vmware-player-with-networking-enabled/http://www.transdroid.org/2011/01/26/techpost-debugging-against-a-virtual-machine-android/
没有网络连接 - VMWare Fusion 上的 Android-x86 http://lkubaski.wordpress.com/2012/08/15/running-android-on-vmware-player-with-networking-enabled/ http://www.transdroid。 org/2011/01/26/techpost-debugging-against-a-virtual-machine-android/
回答by user3491156
To save some time: http://aztcs.org/meeting_notes/winhardsig/Android-vm/Android-VMwarePlayer-Win.pdfGood link to get started in VMWARE
为了节省一些时间:http: //aztcs.org/meeting_notes/winhardsig/Android-vm/Android-VMwarePlayer-Win.pdf开始使用 VMWARE 的好链接
Where in the case you installed in the following directory /opt/android-sdk-linux Set path variables
如果你安装在以下目录 /opt/android-sdk-linux 设置路径变量
export ANDROID_HOME=/opt/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
After performing path if you see the application from typing "android" in the console your path setting is good.
执行路径后,如果您在控制台中键入“android”看到应用程序,则您的路径设置很好。
create a hello world application(get the sdk installed correctly here if you have questions)
创建一个 hello world 应用程序(如果有问题,请在此处正确安装 sdk)
Run the hello world app
运行你好世界应用
Hit ALT-F1 in the VM and use the netcfg command to know the IP address given to your eth0 device. You can then hit ALT-F7 to go back to the Android UI. Then, in your host PC, execute the adb connect [ANDROID_X86_IP] to connect the SDK debugger to your Android x86 VM; for example: adb connect 192.168.1.100:5555. If problems bounce the service adb kill-server ; adb start-server
在 VM 中按 ALT-F1 并使用 netcfg 命令来了解为您的 eth0 设备提供的 IP 地址。然后您可以按 ALT-F7 返回 Android UI。然后,在您的主机 PC 中,执行 adb connect [ANDROID_X86_IP] 将 SDK 调试器连接到您的 Android x86 VM;例如:亚行连接 192.168.1.100:5555。如果问题反弹服务 adb kill-server ; adb 启动服务器
at console change directory to /android-sdks/platform-tools then type
在控制台将目录更改为 /android-sdks/platform-tools 然后输入
./adb connect 192.168.1.100 (note the 192.168.1.100 is what is required it defaults to port 5555)
./adb connect 192.168.1.100(注意 192.168.1.100 是默认端口 5555 所需要的)
I had to use the ./adb prefix and then I was configuring the VMWARE instance.
我不得不使用 ./adb 前缀,然后我正在配置 VMWARE 实例。
I feel allot less greasy avoiding XAML :-)
我觉得避免 XAML 不那么油腻:-)