androidandroid-emulatoremulationnfcopen-nfc

NFC tag emulation for Android virtual device (AVD)


Is there any way to develop NFC tag reading/writing applications without an NFC enabled phone? Is there a way to create an AVD which has NFC enabled? I have searched and found Open NFC exists, but I cannot find much information about it now. Is it already obsolete? Is there any other way to achieve it?


Solution

  • Google never implemented support for NFC in the AVD. So there is no official support for NFC in the Android device emulator.

    Back in the early days of NFC on Android, Inside Secure developed and published the NFC stack "Open NFC". Despite its name, Open NFC was not as open as its name suggested and was primarily targeting Inside's range of NFC frontends. A nice side-effect of that NFC stack was its emulator integration which resembled the capability of Nokia's NFC virtual device support for their series S40 phones. The public files for the Open NFC project are still available on SourceForge: here. However, the project has long been abandoned (probably due to selling their NFC technology to Intel).

    The last version of Open NFC targets Android 4.2.1 (worked with Android 4.2.2), so if that platform was acceptable to you, you could try to setup that AVD environment. A step-by-step guide is available here: Open NFC Simulator Usage (also see here for missing components: Failed to load open-nfc addon in android platform).

    The NFC stack on newer Android versions changed significantly (nowadays, the whole Android NFC stack is based on libnfc-nci which initially targeted Broadcom's NFC controllers and implemented the NFC Forum's NFC Controller Interface specification). As a consequence, the implementation of Open NFC is no longer compatible to more recent Android versions.

    Note that there is still ways to do at least some limited testing through code (e.g. useful for unit tests) by injecting NFC intents. See

    but note that these methods rely on internals of the Android NFC stack and you might need to go through the code for whatever Android version you are targeting to mock the right information.