I have been playing around with Android lately, and one thing that annoyed me is the emulator does not support Bluetooth (as opposed to J2ME emulator, which does).
So if you do not have an actual Android device (like me), and you want to do Bluetooth/WiFi programming, you run in to a problem.
Fortunately, there is a way out - Install the Android image on a VM and use your own Bluetooth device. This is what I did:
I found these links helpful. Perhaps you would too:
http://androiddevnotes.com/2011/03/08/1299521520000.html
http://developer.android.com/guide/topics/wireless/bluetooth.html#EnablingDiscoverability
:)
Happy coding!
So if you do not have an actual Android device (like me), and you want to do Bluetooth/WiFi programming, you run in to a problem.
Fortunately, there is a way out - Install the Android image on a VM and use your own Bluetooth device. This is what I did:
- Download Androidx86 from http://www.android-x86.org/. This is an .iso file, so you'd need something like VMWare or VirtualBox to run it. Me, I use VirtualBox.
- When creating the virtual machine, you need to set the type of guest OS as Linux instead of Other.
- After creating the virtual machine, set the network adapter to 'Bridged'.
- Start the VM and select 'Live CD VESA' at boot.
- Now you need to find out the ip of this VM. Go to terminal in VM (use Alt+F1 & Alt+F7 to toggle) and use the netcfg command to find this.
- Now you need open a command prompt and go to your android install folder (on host). This is usually C:\Program Files\Android\android-sdk\platform-tools>.
- Type adb connect
IP_ADDRESS
- There done! Now you need to add Bluetooth. Plug in your USB Bluetooth dongle.
- In VirtualBox screen, go to Devices>USB devices. Select your dongle.
- Done! now your Android VM has Bluetooth. Try powering on Bluetooth and discovering/paring with other devices.
- Now all that remains is to go to Eclipse, and run your program. The Android AVD manager should show the VM as a device on the list.
I found these links helpful. Perhaps you would too:
http://androiddevnotes.com/2011/03/08/1299521520000.html
http://developer.android.com/guide/topics/wireless/bluetooth.html#EnablingDiscoverability
:)
Happy coding!
i followed the steps and evrything proceeded as mentioned but when i tried to lanch my program from eclipse, the mounted emulator in virtual box wasn't showing in the list of virtual devices, can you explain y??
ReplyDeletehmm did you try typing 'adb devices' in the command prompt to see if the android x86 shows up in the list?
ReplyDeletewhen i use "adb devices" in cmnd prmpt it's displaying nadroid x86's ip in d list of devices attatchd but i cn't see it when i try from avd mannager in eclipse. so i m unable to test my apps through the mounted emulator :-(
ReplyDeleteit's working now, thnx for ur post :-)
ReplyDeleteThanks a lot ! It really helped me.
ReplyDeleteI had some issues with the dongle and had to remove/insert it alteast once before it worked as suggested at:
http://forums.virtualbox.org/viewtopic.php?f=6&t=34867
@dashing & venkat:
ReplyDeleteGlad it was useful guys :)
@ dashing.amitjha: Please tell me how you make your device working.
ReplyDeleteI'm in the same problem.
I installed Android x86 on VirtualBox. There is Bluetooth in my laptop and it works fine, but I cannot turn on Bluetooth in my VM. Is there some specific things to do for laptops?
ReplyDeletei tried adb devices.but the device is not shown in the list.plz help me.
ReplyDelete@Senthil, are you using the virtual device? or an actual device?
ReplyDelete@PDA
I havent tried it on my laptop - but I understand that sometimes this method may not work on all systems. What's your OS?
i tried both virtual box and vmware player.now i am getting connected to ip address as
ReplyDeleteconnected to 127.0.0.1:5555
and when i use adb devices it's coming as
List of devices attached.
emulator-5554 device
127.0.0.1:5555 device.
But i can't see that device in avd manager.I am using pc with bluetooth external dongle.plz hep me.
oh dear...thats strange. its the same problem dashing.amitjha seems to have had. Perhaps contact him and ask?
ReplyDeleteI don't know any details of her.Can you send me plz.
ReplyDelete@senthil
ReplyDeleteI dont either, but you can go to his blogger profile, see his real name and try to find his contact details.
or if his real name is not there, google his blogger name?
ReplyDeleteHmm thanks a lot dear.
ReplyDeleteI found him and sent a friend request to him.Thanks for your suggestion.If you got any solution for this means please help me.
ReplyDeleteFor SENTHIL:
ReplyDelete"adb connect IP_ADDRESS"
IP_ADDRESS != 127.0.0.1
127.0.0.1 = localhost
IP_ADDRESS should be something like your "local ip" :
-ex1 192.168.1.2
-ex2 10.31.5.63
internet is not enabled in the virtual box inspite of setting network adapters. wat cud b d pbm?
ReplyDeletewhich mode did you use? NAT?
DeleteHi friends for me both bluetooth and internet are working.
ReplyDeleteI can't see the virtual machine in AVD manager. Could you help me?
ReplyDeleteI can't see the VM in AVD manager. Could you help me?
ReplyDeleteYou can tell me clearly more about step 8. I don't understand
ReplyDeleteYou can tell me clearly more about step 8. I don't understand
ReplyDeleteIf you dont have built in Bluetooth, you need to add a bluetooth dongle to your PC. Usually, if you're using a Laptop, you dont need to do this step. But for most PCs, you would need to add an external Bluetooth dongle.
DeleteHope you got it now :)
Thank you very much.
DeleteWhen I use my Laptop, I only create one Virtual Machine which has Bluetooth. Is there a way I could test application between two VMs?
Hi Roshini, I am too working on Bluetooth support on Android emulator. I wanted to discuss this with you. Can you write to me at
ReplyDeleteshiningankit@gmail.com
I am too working on Bluetooth support on Android Emulator. I wanted to discuss this with you. Can you write to me at shiningankit@gmail.com
ReplyDeletewe attach usb bluetooth dongle to VM.
ReplyDeleteso we do not deal with bluetooth protocl
only deal with usb.
can paired each divices.But not connected.
ReplyDeleteauthentication is ok,But i can not send files
please help me
i can't understand.you want to send file to emulator?
ReplyDeleteWhy netcfg show only this line : lo UP 127.0.0.1 255.0.0.0
ReplyDeletehello there! with bluetooth enabled in the android emulator, do you think it would it be possible to enable a laptop to send/receive messages and make calls by pairing to devices such as Gmate and SocBlue? thanks!
ReplyDeleteHi,
ReplyDeletehow can I disable ssp mode in Android emulator. Any clue?
I tried hciconfig command to disable but as it's only a bluez lib inside so I cant change the config. Any other clue?
Thanks
Bharat
Hi All,
ReplyDeleteCould anyone help me , how can I disable sspmode in Android emulator.
I tried with hciconfig command, but it failed as it has the bluez built lib only. So cant change the config.
Is there any other way to disable ssp.
Thanks
Bharat
I blog often and I truly appreciate your content.
ReplyDeleteThe article has really peaked my interest. I am
going to book mark your blog and keep checking for new information
about once per week. I subscribed to your RSS feed as well.
Feel free to visit my web blog - great article
heyy can you tell which android x86 .iso file did you use.
ReplyDeletei mean i want my emulator to run atleast ICS.
i everebody,
ReplyDeletei have a problem.i use a usb dongle cc2540(bluetooth low energy) and have then to connect to my PC over VM.but it is not work.i can not see another device, e.g my keyfob (keyfob cc2540 texa instruments).i have do all step by step (Bluetooth support on Android Emulator ).please help me
We're a group of volunteers and opening a new scheme in our
ReplyDeletecommunity. Your site offered us with valuable info to work on.
You have done an impressive job and our entire community will be grateful to you.
my blog post; http://www.incaradvancements.co.uk
I seriously love your blog.. Great colors &
ReplyDeletetheme. Did you develop this site yourself? Please reply back as I'm looking to create
my own personal blog and want to learn where you
got this from or exactly what the theme is called. Kudos!
Also visit my web page :: Throne Rush Cheats