25

I studied about Bluetooth Low Energy.

But I don't have supported BLE device for testing.

Therefore, I want to ask :

Do the Android emulator supports BLE feature for testing?

I tried with the following code on Android Emulator 4.3 (x86) and Android Emulator 4.4 (ARM):

// Use this check to determine whether BLE is supported on the device. Then
// you can selectively disable BLE-related features.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
   Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
   finish();
}

And it always show "ble_not_supported".

Another question is

Which another emulator or tool supports BLE for Android?

I really want to test BLE feature on Emulator.

KhalodaRK84
  • 85
  • 2
  • 14
  • 4
    [The official website](http://developer.android.com/tools/devices/emulator.html) says: "Emulator Limitations: ... No support for Bluetooth" – Michael Dec 03 '13 at 10:41
  • Really thanks for your comment. But how about "Which another emulator or which another tools has supported BLE for Android?" –  Dec 03 '13 at 10:55
  • I don't know. MecApp might support BLE, but it's not free, and it's possible that you'll need at least a Bluetooth dongle for your PC with BLE support to use it. – Michael Dec 03 '13 at 11:11

3 Answers3

25

It seems you can, using Android inside a VirtualBox and using a PC dongle supporting Bluetooth LE (costs about 18$ on Amazon). Here's the tutorial by Chris Larson (copied here to keep it online):

Android emulators are great for developing BluetoothLE applications. The trick is getting the Android emulator to recognize the BluetoothLE adapter.

What you'll need:

  • Androidx86 iso from android-x86.org I used the 4.4 release candidate
  • Virtual Machine software: I used Oracle VirtualBox
  • A BluetoothLE USB adapter: I used the Cirago Bluetooth 4.0 USB Mini Adapter (BTA8000)(affilate link) or Cirago Bluetooth 4.0 USB Mini Adapter (BTA8000) (non-affilate link)
  • Install Android SDK for debugging
  • Install VirtualBox
  • Download Androidx86
  • Open VirtualBox and create a new machine. Set type to linux/other(32bit)
  • Set the virtual machine's memory and harddrive space to whatever you need (but at least the minimum specs for Android).
  • When asked for the OS image, select the Androidx86 image you download from Androidx86.org
  • When the virtual machine boots, choose to install Android.
  • When the installation completes, shutdown the Android virtual machine and unmount the iso image
  • Plug in the Bluetooth USB adapter and add it to the Android Virtual Machine's settings
  • Start the Android Virtual Machine and go through the start-up screens to configure Android for use
  • In the Android VM go to the settings and enable BluetoothLE (if this fails reboot the VM and try to enable again)

Here are a few other links describing more or less the same method, and a few other tools that can be of interest to you:

And if you want this issue to be solved by Google, you can star this thread to make it more visible (with enough votes, Google will tackle it in a few years, as they did with audio issues...):

https://code.google.com/p/android/issues/detail?id=56608

Community
  • 1
  • 1
gaborous
  • 15,832
  • 10
  • 83
  • 102
  • Thank you for this guide! I was able to install android this way. Is there a way to run apps from Android studio in this android instance in virtual box? We are developing a BluetoothLE app that we would like to test with BLE hardware his way. – Reneli Aug 26 '16 at 21:38
  • I don't think there is any compatibility between Android Studio and an Android virtual machine (but you can try to google it), so I guess you will have to compile your app and install it in your VM everytime you want to test it. To automate the process, you can maybe make a post-processing script in Android Studio that would move the compiled APK to your VM using [virtual shared folders](http://www.howtogeek.com/189974/how-to-share-your-computers-files-with-a-virtual-machine/) for example and then [execute your APK in your VM using the VirtualBox API](https://github.com/mjdorma/pyvbox). – gaborous Aug 26 '16 at 21:54
  • @Lukᚊálek you mean running app from Android Studio in a VM? – gaborous Dec 21 '16 at 11:28
19

Using the Emulator said that

Emulator Limitations

The functional limitations of the emulator include:

No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.

No support for USB connections

No support for device-attached headphones

No support for determining network connected state

No support for determining battery charge level and AC charging state

No support for determining SD card insert/eject

No support for Bluetooth

Thanks,

Community
  • 1
  • 1
Huy Tower
  • 7,769
  • 16
  • 61
  • 86
0

There is an BLE simulator in

This is an Android API level simulator.

user3509406
  • 389
  • 1
  • 10