Debugging using a virtual machine like VMWare/VirtualBox?

33,832

Solution 1

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

Working with latest Android X86 4.2 Jelly Bean and Virtual Box

I have found Different ways to connect with Internet and adb

Step: 1 Selection of Adapters

CASE 1: Only 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 adapter

Case 2: Only adb {Host Only Adapter}

The easiest solution is just use Host Only Adapter

Host Only Adapter Settings

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()

Case 3: For both adb and 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

Alternatively if you are with Wifi just do the same by selecting the Wifi adapter

For other type of connection you shall go with the same way

Bridge Adapter

Step: 2 Connection with adb

to check the ip Address just press Alt+F1 {for console Window} [To switch back to Graphics view press Alt+F7 ]

you will see the console window type netcfg

it will show the ip address

Now move on to you host run command prompt move to adb directory type

 adb connect {your ip address}

Example

adb connect 192.168.1.51

Note: if adb is not running or responding you can do following

adb kill-server

adb start-server 

you can check devices connected to adb

adb devices

Solution 2

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;

Hit ALT-F1 in the VM and use the ifconfig command to know the IP address given to your network device (usually eth0). 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.

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:

#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.

If you want to read further, check out the Android-x86 website. It also has a lot of disc images available for download.

Solution 3

  1. install android x86 on vmware

  2. run android terminal write command "ifconfig eth0"

  3. windows user make Environment C:\Users\user- name\AppData\Local\Android\sdk\platform-tools

  4. "adb connect IP address of the VM":5555 now run app on vmware

Solution 4

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?)

a) Use Intel Atom x86 instead of ARM

b) Use hw.gpu.enabled

I would say this makes emulator quite comparable in performance to a real device.

Update 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.

Useful links (which try to accomplish what you want

No network connection - Android-x86 on VMWare Fusion 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/

Share:
33,832
Trikaldarshiii
Author by

Trikaldarshiii

No Me, No Life Know Me, Know Life Coding is my passion, whether it is hardware or software. I am for sustainability, trying as best as possible to create and innovate to make how I live productive so the future generations can live without fear of a non sustainable future. Stack Overflow makes me a better programmer while I can offer my own help to make others better programmers. Last but not the least I am a common man. Just, another common man. And now, I wont sit quiet, I will do whatever I can... I cannot reach publications, I will create my own way of publicity, I cannot reach their government, I will make sure, my message is reached. I cannot make my future anymore but, this is not the future, I will give to my future generation. I am a hacker and nothing can compromise me, not any more... I will fight, I will destroy, I will hit and hit it hard, where it hurts the most; I am not a Warrior with Guns but Brains, I am called, an Indian Cyber Warrior

Updated on December 05, 2020

Comments

  • Trikaldarshiii
    Trikaldarshiii over 3 years

    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

    Can I use it as emulator? If so, how? How can I connect ADB to a virtual machine running PC Android?

    I saw in some forum to use this but my VMs android having no specific IP.

    How to i connect it??

  • Trikaldarshiii
    Trikaldarshiii about 11 years
    i've checked many of the portals for increasing the speed of emulators none of them works although there is better speed in Virtual machine when app runs on that than the emulator but the main question is how to not about alternatives
  • Victor Ronin
    Victor Ronin about 11 years
    Got it. It's kind of strange that Virtual machine works faster then emulator with Intel Atom x86. I believe it uses virtualization too (so they should be comparable). Let me look for information on VMWare or VirtualBox and get back to you.
  • 0x5C91
    0x5C91 about 10 years
    I'm sorry, but the first link is terrible.
  • Demir
    Demir almost 10 years
    Great explanation. Thank you very much.